javascript - AngularJS ng-repeat not rendering $resource -
i'm working on angular app includes user feed page, 1 of items on feed list of groups user belongs to. groups pulled backend through $resource call accepts user id parameters.
the issue facing allgroups (the collection returned $resource call) available in $scope not rendering on page.
here controller setting groups variable:
angular.module('kickitangularfrontendapp') .controller('userctrl', function ($timeout, $scope, user, $rootscope) { $timeout(function() { user.allgroups.query({user_id: $rootscope.user.id}, function(data) { $scope.allgroups = data; }) }, 130); });
here user factory
angular.module('kickitangularfrontendapp') .factory('user', function ($resource) { return { allgroups: $resource('http://localhost:3000/api/users/:user_id/get_groups', { query: { method: 'get', params: {}, isarray: false } }), groupscreated: $resource('http://localhost:3000/api/users/:id/get_groups_created', { query: { method: 'get', params: {}, isarray: false } }), allevents: $resource('http://localhost:3000/api/users/:id/get_events', { query: { method: 'get', params: {}, isarray: false } }), eventscreated: $resource('http://localhost:3000/api/users/:id/get_events_created', { query: { method: 'get', params: {}, isarray: false } }), }; });
here view rendering groups
<div class="col-md-3"> <h3>group feed</h3> <ul class="list-group" ng-controller="userctrl"> <li class="list-group-item" ng-repeat="group in allgroups"></li> </ul> </div>
i can see allgroups object attached userctrl $scope , view ng-inspector not render on page. thought because $resource request requires id of $rootscope.user object set after page loads not available rendered.
if indeed case, how go solving it? appreciated.
also, using angular ui-router if helps.
Comments
Post a Comment