Posts

Showing posts from October, 2016

AngularJs -Effective way to Monitor Changes to Model data

Image
The two-way data binding in AngularJS is very powerful, especially when there is a direct mapping of input data to view-model-data. But, when the data mapping requires some translation, interpretation, or validation, you need to get your hands a little dirty - you need to get more involved in how data changes are propagated within your Controller(s). As this has happened to me, I've been forced to think more deeply about my AngularJS application architecture; and, as a result, I've found that my life is often simplified (in the long term) by calling a directive to watch before I bind the data to View model. Factory To Monitor Changes This is easiest and effective way because of these reasons : 1) I just need to call a Trigger Method with scope which should be monitored 2) Once the data is retrieved from Ajax call , I just Initialize the data 3) If there are any changes to bound data on the form and user tries to navigate to another page, I get Confirm box on the