i have setup service fetch list of items, controller list, , view iterate through , display each item.
thing is, items links rss feeds , in controller want parse through these rss feeds , set model data view handle.
now, there more modifications modelling done (i need model actual rss feed content), first problem data fetched service not modifiable in controller (since call hasn't finished, @ time try access it, guess). it's empty array if write console.
so i'd need know how trigger data operations in controller once service call has finished.
thanks!! // joakim
service code:
angular.module('itemfeedservices', ['ngresource']). factory('item', function($resource){ return $resource('items/:itemid.json', {}, { query: {method:'get', params:{itemid:'items'}, isarray:true} }); });
controller code:
function itemlistctrl($scope, item) { $scope.items = item.query(); console.log($scope.items); // gives [] }
basically, think want callback? documentation says:
the action methods on class object or instance object can invoked following parameters: http "class" actions: resource.action([parameters], [success], [error]) non-get "class" actions: resource.action([parameters], postdata, [success], [error]) non-get instance actions: instance.$action([parameters], [success], [error])
so, using:
item.query({}, function() { //you callback });
should work.
Comments
Post a Comment