There are many methods in AngularJs some of them are give below.
$watch - Registers a
The
The
$apply -
$watch - Registers a
listener
callback to be executed whenever the watchExpression
changes.The
watchExpression
is called on every call to $digest() and should return the value that will be watched. (watchExpression
should not change its value when executed multiple times with the same input because it may be executed multiple times by $digest().The
listener
is called only when the value from the current watchExpression
and the previous call to watchExpression
are not equal. example - scope.$watch('name', function(newValue, oldValue) {
scope.counter = scope.counter + 1;
});
$watchgroup - A variant of $watch() where it watches an array of watchExpressions
. If any one expression in the collection changes the listener
is executed.$apply -
$apply()
is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life cycle of exception handling, executing watches.function $apply(expr) {
try {
return $eval(expr);
} catch (e) {
$exceptionHandler(e);
} finally {
$root.$digest();
}
}
Scope's
$apply()
method transitions through the following stages:- The expression is executed using the $eval() method.
- Any exceptions from the execution of the expression are forwarded to the $exceptionHandler service.
- The watch listeners are fired immediately after the expression was executed using the $digest() method.
$digest()
keeps calling the watchers until no more listeners are firing. This means that it is possible to get into an infinite loop. This function will throw 'Maximum iteration limit exceeded.'
if the number of iterations exceeds 10.
Usually, you don't call
$digest()
directly in controllers or in directives. Instead, you should call $apply() (typically from within a directive), which will force a $digest().
var scope = ...;
scope.name = 'misko';
scope.counter = 0;
expect(scope.counter).toEqual(0);
scope.$watch('name', function(newValue, oldValue) {
scope.counter = scope.counter + 1;
});
expect(scope.counter).toEqual(0);
scope.$digest();
// the listener is always called during the first $digest loop after it was registered
expect(scope.counter).toEqual(1);
scope.$digest();
// but now it will not be called unless the value changes
expect(scope.counter).toEqual(1);
scope.name = 'adam';
scope.$digest();
expect(scope.counter).toEqual(2);
$destroy - Removes the current scope (and all of its children) from the parent scope. Removal implies that calls to $digest() will no longer propagate to the current scope and its children. Removal also implies that the current scope is eligible for garbage collection.
The
$destroy()
is usually used by directives such as ngRepeat for managing the unrolling of the loop.
$eval - Executes the
expression
on the current scope and returns the result. Any exceptions in the expression are propagated (uncaught). This is useful when evaluating Angular expressions.var scope = ng.$rootScope.Scope();
scope.a = 1;
scope.b = 2;
expect(scope.$eval('a+b')).toEqual(3);
expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3);
$evalAsync- Executes the expression on the current scope at a later point in time.
For other methods click $digest $eval $destry, $apply etc
The
$evalAsync
makes no guarantees as to when the expression
will be executed, only that:- it will execute after the function that scheduled the evaluation (preferably before DOM rendering).
- at least one $digest cycle will be performed after
expression
execution.
Just wish to say your article is as astounding. The clearness in your
ReplyDeletesubmit is just excellent and i can suppose you’re knowledgeable in this subject.
Well along with your permission allow me to take hold of your RSS feed to stay up to date with drawing close post. Thanks a million and please carry on the rewarding work.
Read More:
AngularJS Certification Training in Chennai
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeletejava training in chennai | java training in bangalore
java online training | java training in pune
java training in chennai | java training in bangalore
java training in tambaram
Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
ReplyDeletepython training in omr
python training in annanagar | python training in chennai
python training in marathahalli | python training in btm layout
python training in rajaji nagar | python training in jayanagar
Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
ReplyDeleteMEAN stack training in Chennai
MEAN stack training in bangalore
MEAN stack training in tambaram
MEAN stack training in annanagar
MEAN stack training in Velachery
MEAN stack training Sholinganallur
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleterpa training in marathahalli
rpa training in btm
rpa training in kalyan nagar
rpa training in electronic city
rpa training in chennai
rpa training in pune
rpa online training
Appreciating the persistence you put into your blog and detailed information you provide
ReplyDeleteData Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in OMR
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore
Data Science training in marathahalli
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.
ReplyDeleteDevops Training in pune|Devops training in tambaram|Devops training in velachery|Devops training in annanagar
DevOps online Training
This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me..
ReplyDeletepython training in rajajinagar
Python training in btm
Python training in usa
java online training | java training in pune
ReplyDeletejava training in chennai | java training in bangalore
Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.
ReplyDeletepython training in annanagar
python training in chennai
python training in chennai
python training in Bangalore
This is such a great post, and was thinking much the same myself. Another great update.
ReplyDeleteangularjs Training
in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
ReplyDeleteHello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
ReplyDeleteData Science training in rajaji nagar | Data Science with Python training in chenni
Data Science training in electronic city | Data Science training in USA
Data science training in pune | Data science training in kalyan nagar
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteBest Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
ReplyDeleteAWS Training in Pune | Best Amazon Web Services Training in Pune
AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners
Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai
AWS Training in Chennai |Best Amazon Web Services Training in Chennai
Amazon Web Services Training in Pune | Best AWS Training in Pune
Inspiring article, all your points are worth to learn. Cheers and thanks for the clear path
ReplyDeleteSelenium Training in Chennai
software testing selenium training
ios developer course in chennai
Digital Marketing Course in Chennai
dot net course
dot net coaching centers in chennai
c# training in chennai
Big Data Training in Chennai
I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training