angularjs - How to change data into Angular 1.5 Component via an external Service? -
i make app angular 1.5 components. provide data component via resolve
parameter, in way can display data different sources in same component. don't understand, how change data in component.
for example, have user service, works users through api. in state load component , use method users.get(). use ui router.
//... $stateprovider .state('users', { url: '/users', component: 'formpage', resolve: { values: function(users) { return users.get(); }); //... //... component('formpage', { bindings: { values: '<' }, //...
i have form in component , want change data. want call users.update() method, when form submitted. component don't know users service , that's right.
how may specify component must use users.update() update data in state? , how call method in component when form submitted?
resolve: { values: function(users) { return users.get(); }, onupdate: function(){ return users.update.bind(users); } ); bindings: { values: '<', onupdate: '<' },
and can call $ctrl.onupdate(data).then(...
Comments
Post a Comment