What are the type of watch

0 votes
Can someone help me with the general syntax of $watch() types and explain it??
Feb 3, 2020 in Angular by kartik
• 37,520 points
1,005 views

1 answer to this question.

0 votes

hey kartik,

Before you move in to the topic do check- $watch and watch listener function first.

$watch() function is used to watch the changes of variables in $scope object and watch listener is a function that is executed automatically when variable changes its value at its scope.

Generally,there are four types of $watch(). They are:-

1.) $watch-reference watch:

"o" is a object has the property contain in it. For object "o" watch listener function is created and the event will fire only if object "o" will assign to other object.

[Note]: No changes will occur if object's "o" property is modify. 

2.) $watch with "true"- Equality watch:

    Equality watch is same as Reference watch but the only difference is that if you provide "true" value in watch listener function at the end it will allow event to be fire even object "o" property is chnaged.

3:) $watch group:

watch group function is used to manipulate watch scope of the variable that is not binded to no scope. Simply we can use array of several other scope variable

4:)Collection watch:

It is used to watch array. It can also be used to detect modification to an array (i.e adding or deleting). However to achieve this use Equality watch.

here scope emp contains data, However if we add items to it then watch function event will fire automatically if we push data to emp array 

{Note}: It will not execute if any modification of arrays data will occur.(executed only if any add or deletion will take place in an array).

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

Related Questions In Angular

0 votes
1 answer

What are the $route service Events provide in AngularJs?

hey, $route is used for deep-linking URLs to controllers ...READ MORE

answered Feb 10, 2020 in Angular by Niroj
• 82,840 points
1,079 views
0 votes
1 answer

What is the top advantages of using UI-router over ngRoute?

Hey, In Client side Routing there are several ...READ MORE

answered Feb 11, 2020 in Angular by anonymous
• 82,840 points
1,194 views
0 votes
1 answer

What are the features supported in UI-Router Parameters?

UI-Route describes how the UI looks like ...READ MORE

answered Feb 11, 2020 in Angular by Niroj
• 82,840 points
858 views
0 votes
1 answer

What is $watch() and it's use in AngularJS?

$watch() function is used to watch the ...READ MORE

answered Feb 3, 2020 in Angular by anonymous
• 82,840 points
2,516 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,520 points
954 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,191 views
+1 vote
1 answer

What are pseudo class in css??

Hey, The state of an element is controlled  by ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 927 views
0 votes
1 answer

What is the use of $eval in alert()?

Hey, kartik!! There is not much difference in ...READ MORE

answered Feb 4, 2020 in Angular by Niroj
• 82,840 points
1,338 views
0 votes
1 answer

What are the steps involved in ng-route in AngularJS?

Hello, As Routing is just another way of fixing some content ...READ MORE

answered Feb 6, 2020 in Angular by Niroj
• 82,840 points
1,078 views
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