What is watch listener function in AngularJs

0 votes
I wanted to know when to be used watch listener function in AngularJs and what was its general Syntax?
Feb 3, 2020 in Angular by anonymous
• 37,510 points
1,292 views

1 answer to this question.

0 votes

Hii,

Before you know what's the use of  watch listener function-You should know what is $watch()  function,for this you can check it out-$watch().

Watch Listener is a function that can be used explicitly to $watch certain variables. It is used when a variable doesn't have any data binding for its scope.

So to create any explicit $watch() for a variable we can use watch listener function.

However, Watch listener function is also available for $rootscope as well implicitly.

The general syntax for watch listener function is/are:

Here,Watch listener function is created for variable 'a' explicitly. The event of these variable 'a' will be executed automatically when variable change its value, then the watch listener function will be executed.

The parameter new value is the value that variable 'a' has new manipulated value whereas old value are the past values.

Hope this helps!

To know more about Angular, It's recommended to join Angular online training today.

Thanks.

answered Feb 3, 2020 by Niroj
• 82,880 points
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP