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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -