angularjs - Setting up Angular service in Controller using routeProvider -
i have following:
when('/admin/foo', { controller: foolistctrl, templateurl: 'frontend/partials/admin/foo-list.html', resolve: { aliasnames: ['printingservice', function(printingservice){ return printingservice.listarray(????); }] } }).
the controller:
function foolistctrl($scope, restangular, aliasnames) { $scope.aliasnames= aliasnames; }
the printingservice:
app.service('printingservice', [function() { return { listarray: function(thearray) { var result= "{"; result += thearray.join(", "); result += "}"; return result; } }; }]);
im html page, have ng-repeat, , each object in repeat has array, i'm wondering how call service using each object's array. ng-repeat loop on objects have array, , need pass each array service, example:
<div ng-repeat="obj in objects">{{obj.names}}</div>
how pass each obj.names printingservice?
save reference of service in controller's scope , invoke view :
js: function foolistctrl($scope, restangular, aliasnames, printingservice) { $scope.aliasnames= aliasnames; $scope.printingservice = printingservice; }
and in html :
<div ng-repeat="obj in objects">{{printingservice.listarray(obj.names)}}</div>
Comments
Post a Comment