Hello i know how to get the errors from a laravel validation but now my problem is displaying them. I want a simple way of looping through each error message and displaying on the users page using ng-repeat.
This is a sample of my code:
var req = {
method: 'POST',
url: '/customer',
headers: {
'X-XSRF-Token': $("meta[name='csrf_token']").attr("content")
},
data: {
fullname: $scope.customer.input.fullname,
address: $scope.customer.input.address,
telephone: $scope.customer.input.telephone,
email: $scope.customer.input.email,
city: $scope.customer.input.city
}
}
$http(req)
.success(function (data, status, headers, config) {
if (data.url !== undefined)
{
window.location.href = data.url;
}
})
.error(function (data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
//alert(data);
});
Example of returned object:
{"email":["The email has already been taken.","Email field is required"],"password":["The password must be at least 8 characters
."]}
How would i loop through an object like that and display each message vertically on the users page. I use bootstrap css framework.