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 in Angular by anonymous
• 1,910 points
21 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.

answered Feb 3 by Niroj
• 3,230 points