Say I have a service that holds my data for a view or a few views and it looks like this.
angular.module('testApp').factory('MyService', MyService);
function MyService() {
var data = {name: "Bill"};
return {
getData: getData
};
function getData() {
return data;
}
}
And in my controller I have it as this:
view.data = MyService.getData;
And I bind it to my model like this:
<input type="text" ng-model="myCtrl.data().name"/>
This binds the service's getter function to the ng-model and makes it so I never have to worry about updating my controller with service data and the other way around. My question, is there any negative effects to doing things this way? Performance effects with the $watcher calling numerous getters functions?