I saw a lot of documentation about smart and dumb components. For example:
angular.module('myList', []).component('myList', {
bindings: {
items: '<',
onDelete: '&'
},
templateUrl: 'my_list.template.html' });
When I click on a button with an "onDelete" binding, the smart component execute a function in a service, the service call to the server/API and refresh the items object on the above dumb component. Ok, cool.
My question is, what happend if the server returns an error? I'd like to show that error inside the my_list.template.html template. Do I need to add an '<error'
binding?
Another doub. If I have a form on myList component, and I want to reset the form (and many other things...) when the server finish the onDelete execution, what is the more elegant way to do this? (to do it I return a promise in the onDelete function but I don't like it much)
var promise=vm.onDelete({item:item});
promise.then(...);
Thanks
Aucun commentaire:
Enregistrer un commentaire