February 10, 2015

Stop and Resume Binding in AngularJS

Hi,

There comes a time when you need to tweak the native behavior of a framework.
For me it was pretty straight forward desire to stop and resume binding for DOM elements.

The reason behind it was that sometimes I have several elements on the DOM which listen to the same data, but not all of them are viewable. Only one of them is viewable and this is the one I would like the binding to keep updating, while the rest shut the hell up and do nothing over the data changes.

AngularJs is not too kind when it comes to tempering with it's biding mechanism and I guess they have they reasons. The binding mechanism is something that can dramatically affect the performance of an application.

If you go little bit deeper (really, no too deep) you find that binding is all about the digest cycle which in turn invoke watchers, which are functions set to watch for changes and invoke callback accordingly. It is these $$watchers which you would like to remove and retrieve in order to connect and disconnect to the digest cycle.

I've made a simple POC where I created DOM with 2 identical directive bound to the same data on their parent scope. I also added buttons to toggle their binding - pressing it once cuts off the binding for a specific directive while the other keeps on updating. Another click resumes the binding.

Simple - you can find the code here on Plunker

Take care.






23 comments:

Raju Kumar said...

Thanks for sharing with us that awesome article you have amazing blog.....
Angularjs Training In Hyderabad

osvaldo anderson said...

I think that Angular.JS is perfect for Single Page Applications.

caroline jesi said...

Thanks for sharing about Angular,It’s a structural framework for dynamic web application; it lets you extend the syntax of HTML to demonstrate your apps components clearly. All functionality happens inside the browser making it an ultimate companion with any server technology.
Regards,
Angularjs training in chennai|Angularjs course in chennai

Priya said...



The oracle database is capable of storing the data in two forms such as logically in the form of table spaces and physically like data files.
Oracle Training in Chennai | oracle dba training in chennai

geethu said...

Angularjs is the great javascript framework that has some compelling features not for developers but also for the designers. Angularjs is very essential for the web developers to know about its importance.
Angularjs Training in Chennai | angularjs course in chennai

for IT the said...

I have read your blog its very attractive and impressive. I like it your blog.

Angularjs Online Training Angularjs Training Angularjs Training Angularjs Training in Chennai Angularjs Training in Chennai Angularjs Course Angularjs Course Angular 2 Training in Chennai

Kamalakar said...


I Visited lot of blogs and Web sites But in this AngularJS Blog Information is Very usefulthanks for sharing it........

Oracle dba certification cost in chennai said...

Thanks to shared this valuable news with me.
Oracle courses | DBA course

venu puram said...

Hello,

Thank you for sharing about AngularJS and well AngularJS is an evergreen field. While I was having my PMP Course in Kuwait I was supposed to know about AngularJS Which is having a good platform over all courses comparing with PMP.
Thankyou so much for the article Keep Updating

Rajesh Developer said...

It's very nice blog. I'm so happy to gain some knowledge from here. Thank you for valuable information on
AngularJS Training in Chennai.
Hoping to get more info...

Nazeer Rahaman said...

AngularJS is one of the best course to be taken I hope to get more information about AngularJS , As I completed my PMP Training in Chennai and I also want to take AngularJS course Which adds more value to my Profile

kokilak karthick said...

Thanks for sharing this post. Its really useful for learning angularjs.
AngularJS training courses in chennai

Richard Swayar said...

Australia Best Tutor is one of the best Online Assignment Help providers at an affordable price. Here All Learners or Students are getting best quality assignment help with reference and styles formatting.

Visit us for more Information

Australia Best Tutor
Sydney, NSW, Australia
Call @ +61-730-407-305
Live Chat @ https://www.australiabesttutor.com




Our Services

Online assignment help Australia
my assignment help Australia
assignment help
help with assignment
Online instant assignment help
Online Assignment help Services

prachi sara said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
Hadoop Training Institute In chennai

Arvind Rawat said...

Each department of CAD have specific programmes which, while completed could provide you with a recognisable qualification that could assist you get a job in anything design enterprise which you would really like.

AutoCAD training in Noida

AutoCAD training institute in Noida


Best AutoCAD training institute in Noida

Arvind Rawat said...

Each department of CAD have specific programmes which, while completed could provide you with a recognisable qualification that could assist you get a job in anything design enterprise which you would really like.

AutoCAD training in Noida

AutoCAD training institute in Noida


Best AutoCAD training institute in Noida

Unknown said...

I am really happy with your blog because your article is very unique and powerful for new reader.
selenium training in chennai

pooja saravanan said...

Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.

Blueprism training in Chennai

Blueprism training in Bangalore

Blueprism training in Pune

Blueprism training in tambaram

Blueprism training in annanagar

Blueprism training in velachery

Blueprism training in marathahalli

gowsalya saranya said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Devops training in tambaram|Devops training in velachery|Devops training in annanagar|Devops training in sholinganallur

amarraj paindit said...

rpa training institute in noida
sas training institute in noida
hadoop training institute in noida
blokchain traninig institute noida


Saro said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

rpa training in electronic city | rpa training in chennai

rpa online training | selenium training in training

sai said...

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
python training in rajajinagar
Python training in btm
Python training in usa
Python training in marathahalli

indhumati said...

Such an excellent and interesting blog, Do post like this more with more information, This was very useful, Thank you.
Angularjs courses in Chennai
Angular Training in Chennai