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,520 points

1 answer to this question.

0 votes


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.

answered Feb 3, 2020 by Niroj
• 82,760 points