angularjs - How to declare a watch on the this object in a factory method in angular js? -
i have factory class defined instantiating in controller.
i want define method in factory declaration of user class notified when of properties changed .
below link code @ code pen
app.factory('user', ['$rootscope', function ($rootscope) { function user(userdata) { user.prototype.name = userdata.namesample; user.prototype.age = userdata.age; $rootscope.$watch(this, function (oldvalue, newvalue) { }, true); }; user.prototype = { name: null, age: null } return user; }]);
Comments
Post a Comment