Hi, I am trying to figure out how to solve this issue. I tried referencing the service. I tried using $scope.$watch. nothing is working for me. 10x in advanced for your help. TD
I put the sample code here: http://jsfiddle.net/xye4A/5/ <div ng-app="ExampleApplication"> <div ng-controller="InstanceController"> <div ng-click="click()">click</div> <div>|{{i.name}}|</div> </div> </div> var ExampleApplication = angular.module('ExampleApplication', []); ExampleApplication.service('instancedService', [instancedService]); function instancedService(){ var i = {name: "x"}; var service = { i: i, click: click}; return service; function click() { i = {name: "y"}; alert(i.name); } } ExampleApplication.controller('InstanceController', function($scope, instancedService){ var vm = $scope; vm.i = instancedService.i; vm.click = function () { instancedService.click(); alert(instancedService.i.name); }; $scope.$watch( function(){ return instancedService.i }, function(newVal) { $scope.i = newVal; }); }); -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
