http://stackoverflow.com/questions/20054028/how-to-call-a-service-function-in-angularjs-ng-click-or-ng-change
For example, most services relating to reusable view states I write are simply a set of functions, with one exposing the underlying data.
return {
getData: function() { return container; },
doSomethingOnData: function() { /* some manipulation of container */ }
};
Now you can access the service data by attaching it simply to a $scope
variable:
$scope.serviceData = MyService.getData();
So your options for accessing service functions are either to go with Whizkids answer and create wrapping functions attached to scope, or to expose the service directly to the view.
$scope.$MyService = MyService;
To which you could do something like:
<div ng-click="$MyService.doSomethingOnData()"></div>
While this practice strictly goes against angulars separation principles, it does make the code concise if you have a lot of functions within your service you need to expose with simple wrappers.