Reputation: 1241
.success(function (data) {
console.log(data);
$http.put("/admin/" + response.data._id + "/facilities", {
update: { $push: { facilities: data.facility._id } }
}).success(function (data) {
$window.location.href='/admin/registrationSuccess';
});
});
}, function (response) {
$scope.list = response.data.error;
});
.form-group.col-lg-7
label(for='username') Username:
input.form-control(type='text', ng-model = 'username', placeholder='Enter Username', required='')
p {{list}}
Right now I am using angular expressions {{}} to show error. But I would like to pop up a model in case of error containing the response.data.error. Is it possible to have a model whose value will be true if the server sends error response. Anyway what will be the best way to show errors using controllers?
Upvotes: 3
Views: 180
Reputation: 243
You can use angular-ui-notification to show notifications. Below is Github link
https://github.com/alexcrack/angular-ui-notification
// Simple PUT request example:
var req = {
method: 'PUT',
url: '/someUrl',
headers: {
'Content-Type': 'application/json'
},
data: { test: 'test' }
}
$http(req).then(function successCallback(response) {
// Here you can process successful response
// Show notification
Notification.success({message: 'Success notification'});
}, function errorCallback(response) {
// Here you can process error
// Show notification
Notification.error({message: 'Error notification'});
});
Upvotes: 1