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 .

enter image description here

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; }]); 

http://codepen.io/anon/pen/qjwywp?editors=101


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -