My Backend API is built on Laravel 5.2 and the Frontend uses AngularJS. During a Laravel validation process, I check for errors and return an error message if validation fails.
However, when I display these errors on the frontend, they appear in the format:
["The email has already been taken."]
I want to display them like this instead:
The email has already been taken.
without the [""] surrounding the message.
Here's a snippet of my code:
Angular controller:
if (error.statusText === "Unprocessable Entity") {
$scope.registerErrors = error.data;
}
Angular template:
<div class="alert alert-warning animated pulse" ng-if="registerError && isLoading === false">
<p ng-repeat="(error, errorText) in registerErrors">{{errorText}}</p>
</div>
Laravel controller:
$this->validate($request, [
'firstname' => 'required|max:100|min:3',
'lastname' => 'required|max:100|min:3',
'email' => 'required|email|unique:users|max:255',
]);
Console.log:
https://i.sstatic.net/zbN1N.png
Thank you in advance!