The AngularJS watch listener may change the model, which may trigger other listeners to fire. This is achieved by rerunning the watchers until no changes are detected.

learn more… | top users | synonyms

0
votes
1answer
35 views

$scope.watch does not work between two different angular pages

the below code is working within one page with different controlloers, but scope.watch does not work when I pass value from one page to another. How can you do that? below is my code. .factory('Data'...
0
votes
1answer
29 views

How can i use $watch in changing column value in a table

In my project-I have two columns in a table.you can see that in below picture. What i want that is-- in "Non Receive Quantity" column if i change some value it will effect accordingly to "order ...
8
votes
1answer
122 views

Angularjs: why there are 3 watchers for 1 binding?

Please take a look at the screen shot given below As you can see in the screen shot above there are #3 watchers for a single binding. Can anyone please elaborate why is it so? P.S: I am using ...
0
votes
0answers
28 views

$watch does`t react on element.innerHeight()

I hava a directive that should react ($watch) if I resize the window. A directive react only on innerWidth but not on innerHeight. I cant solve this problem. Can someone help me? Here is my ...
0
votes
0answers
28 views

AngularJS 1.5.8 + SocketsIO for real time alerts

i have a factory that use socketsIO to get messages from the API in real time. The factory works sweet getting values along the time and showing in the console. My issue is storing that values in an ...
0
votes
1answer
31 views

How can I update a parentScope array when it changes in the childScope in Angular?

I have a main controller with a nested child controller <div class='main' ng-controller='mainController'> <div class='search' ng-controller='searchController'> <input type='...
2
votes
1answer
88 views

Unit Test angularjs directive with watch on element height

I am planning to unit test a angular directive using jasmine. My directive looks like this angular.module('xyz.directive').directive('sizeListener', function ($scope) { return { link: function(...
0
votes
0answers
30 views

Angularjs using a factory properly

I was wondering if you could help. I have the below code which sets a timeout delay before making a http request. The watch is bound to a input box. This is currently in my controller and it works. ...
0
votes
2answers
104 views

AngularJs Call function on hidden input on value change $watch

I want to use $watch in order to trigger a function each time one of those 3 values is changed : html: <input type="hidden" name="source_x" id="source_x" ng-model="source_x"/> <input type="...
0
votes
3answers
32 views

Hide items of autocomplete with watch Angularjs

I'm trying to make an autocomplete with $scope.watch, and it work perfect but when I choose an option, doing click in the item, it put on the input but the items don't hide because when I put it in ...
0
votes
1answer
20 views

Function scope messes with AngularJS Watches

I'm currently in a situation where I need to create a few watches based on the properties of an object. These properties are used to group functions that depend on the same variable / expression. ...
0
votes
2answers
99 views

What happens behind the scenes when binding to a function in AngularJS

Can anyone explain what happens behind the scenes when you bind to a function in AngularJS? What kind of watch does it create? I have a feeling it would create two watches (in my example below) one ...
1
vote
1answer
60 views

What is the correct way to watch an element's height in AngularJS 1.4.8?

I realize that there are SO posts out there asking similar or even the same thing, but before you mash the duplicate button, be aware I have tried the solution from every single one, and none of them ...
1
vote
1answer
60 views

Angular $watch not working on controller variable updated by directive

I am trying to place a watch on controller variable which gets updated from a directive using function mapping. variable is getting updated and logged in console but watch on it not working. Code ...
0
votes
1answer
35 views

$watch not updating subview

I have this directive that changes $scope.mode in the parent $scope: angular.module('Selector', []).directive('mySelector', function() { var changeMode; changeMode = function(newmode) { var $...
0
votes
1answer
84 views

Change ngModel that was assigned to a directive on a callback from that directive

So I have my SPA application. Here on plunker (I'll not paste all the code, as it is too much) you can see the it's parts recreation (the structure and the hierarchy are the same). Where did the ...
1
vote
1answer
104 views

$watch in post link of compile not working

I am trying to apply $watch on a attribute in the post link function. My code is like this : compile: function(){ return { post:function(scope,element){ scope.$watch('...
0
votes
1answer
51 views

Angular unit testing watcher with parent variable

How can watcher be tested if it watches $parent scope variable? For example I have got in childs scope: $scope.$parent.$watch('activeId', function (hotelId) { $scope.select(activeId); }); ...
1
vote
2answers
42 views

angular $scope.$watch on array calling update function

In my plunk I have an array of integers, that I have attached $scope.$watch to. When I update the array, my $scope.$watch isnt firing a console.log. Why is my console.log not being called? <!...
0
votes
2answers
151 views

AngulaJS with typescript cannot access angular services in directive link function

I am pretty new in typescript and I am trying to create Angular.js directive written using typescript class and want to use external angular services in directive link function, invoked when $watch ...
0
votes
1answer
41 views

Angular $watch is not triggering

I have a text input with eonasdan datetimepicker. There is a bootstrap tooltip for that. I want to hide the tooltip when the datetimpicker is active. There is css class (.bootstrap-datetimepicker-...
2
votes
0answers
136 views

$watch on child element

I've been working on the directive 'input-container' where I need to add a $watch on the child's input ng-model. How am I supposed to do that? <input-container> <label>Doc</...
0
votes
1answer
217 views

$scope.$watch only triggered once

I've set the following watcher in my controller: var embeds = {twitter: false, facebook: false}; $scope.$watch(embeds, function(newVal, oldVal) { if(embeds.twitter && embeds.facebook) $...
0
votes
2answers
184 views

Detect who change the model (user input vs controller) angularjs

I have an input which connected to model. Also, the input has directive which $watch the model. There are 2 ways that the model will change. The user will type in the textbox. The code will change ...
2
votes
2answers
103 views

$watch is not calling inside tabs in angularjs?

Here's my example on Plunker Hi All, In my example, I created two input text boxes, one is outside the tab another one is inside. For both I created a watch function. The outside one is working fine,...
1
vote
1answer
91 views

$watch to check varible defined in the scope AngularJS

I have the following directive to show alerts, so I want catch when the show varible change to star run a timeout how I can do that? the link function was invoked only the first time but all ...
1
vote
1answer
196 views

AngularJS $watch not working in if-block

I figured out, that my angular script is working: $scope.CurrentUser = null; $scope.DatePicker = new Date(); $scope.$watch('DatePicker', function (newValue, oldValue) { if (newValue > new Date(...
1
vote
3answers
50 views

$watch in controller not firing on pushing items into array in directive

I have a two-way binded variable publish.selected_tags between a directive and a controller. I have kept a $watch on that variable in my controller: $scope.$watch('publish.selected_tags', function(...
1
vote
2answers
177 views

Directive scope.$watch called after controller function

So I have a controller and directive. I am having trouble understanding why my controller runs after my directive. I have scoured stack trying to find the answer but it seems like most of the answers ...
2
votes
2answers
469 views

AngularJS '$watch' not firing when value is changed

I have a web app that must be viewed with the landscape orientation. To do this, I have created a function that checks the innerWidth and innderHeight, and if the width is greater than the height ...
1
vote
1answer
154 views

scope.$watch not firing on variable change

I have the following snippet of code below. The problem I'm having is that whenever the value of modal.isOpen is set to true, the $watch statement does not fire. I'm trying to avoid using scope.$apply....
0
votes
2answers
115 views

Can you reuse $scope.$watch

I found some code I want to copy / paste and use in two controllers. It watches something. $scope.$watch('thing', function (thing) { // do cool stuff with thing } Instead of copy/paste, I'd like ...
0
votes
2answers
600 views

How to return multiple values in scope.watch?

I am trying to return multiple values from $scope.watch function. angular.module("MainApp") .directive('isActiveNav', [ '$location', function($location) { return { restrict: 'A', link: ...
0
votes
1answer
23 views

Design relationship between two AngularJS services, for Login and for API

this is more a Design question: I have an angularJS app, this app, uses a Service to communicate with an API which has a sign-in functionality... app.service('managerApiService', function($q){ ...
1
vote
2answers
885 views

Dynamically add $watch

I have a JSON dataset that each row includes an input value, a small block of JavaScript code used to calculate and a subtotal value that is the result of the input value after an eval() preforms the ...
0
votes
1answer
177 views

need to postpone watch on input model till mouse leave or tab enter in Angularjs application

I am using ag-grid with cell renderer as input box, as I am facing problem to fire event on ng-blur in ag-grid, I have tried with $watch on ng-model of the input box. Now the event is firing whenever ...
0
votes
1answer
93 views

Why is my $watch function returning undefined?

Here is my watch function, below... it's currently watching a function in my ViewFactory. // Watch for when tagsFilterModal is showing: vs.$watch('ViewFactory.retrieveSavedViews()', function(newVal) {...
0
votes
1answer
93 views

AngularJS $watch multiple items

What I'm trying to achieve: Watch 'Height','Chest','Waist','Hips' & 'Thigh' scopes, on change update $storage array. Current Problem: Although the below works, I'm having to repeat each section 5 ...
0
votes
2answers
132 views

Angular $watch just parent object instead of its multiple children

I have a div, listing properties of the object POI = {"address":"Martinsicuro (TE), Italy", "phone":"+39 333 45657", "website':'http://mysite.it"}. The object POI si owned by a Service. The directive'...
0
votes
0answers
41 views

how to call function while element content text has changed using apply or anything outside of angular controller

I need to call a javascript function when a particular element content text has changed. How to do this? I have tried this code but to no use. I want to call a callback function when the #...
1
vote
1answer
335 views

why is $watch value parameter sometimes a string value and sometimes a function?

I've seen cases where the first parameter of a $watch is simply a string rather than a function. When do you use a function and when do you use the string? In this plunker, I did this both ways. The $...
1
vote
0answers
50 views

How do you $watch input in ng-repeat separately and append result to specific row in angular js?

I have two input fields b_price and s_price inside ng-repeat. I need to watch changes in these two models and append estimated. My code snippet: html <body ng-app="testthis" ng-controller="...
0
votes
1answer
91 views

how can i get information about who change the variable i set in the watch (angular)

example $scope.$watch('data', function(){}); The function starts when data will change but if I want to know what function cause to the change.
2
votes
1answer
179 views

$watch not updating when service object is updated

I have discovered a perplexing circumstance in which the $scope.watch is not triggering as I would expect. I am hoping some of you AngularJS buffs out there can help shed some light on why Angular is ...
1
vote
1answer
134 views

$scope.$watch not catching the value modified by directive

My directive give focus to my span and assigns boolean value i.e, focusToSpan to true whenever I press shifttab,however, this change is not reflected in my controller and in the template. I even ...
0
votes
0answers
874 views

angularjs scope.$watch old value is always same as new value

Problem in short - $scope.$watch inside an angularjs controller is always getting newValue and oldValues as same. Details : I am writing an angularjs app with three use-cases : createProduct, ...
5
votes
2answers
166 views

What is considered a watcher in Angular?

What are considered "watchers" in Angular? Are watchers themselves the only type of watchers, or are other Angular constructs such as ngModel watchers as well? Or am I missing the big picture? For ...
1
vote
1answer
160 views

$watch is not working in Modal even though using like $scope.user={pwd1:''}

Please refer my Plunker link : http://plnkr.co/edit/0vOjw0?p=preview index.html <!DOCTYPE html> <html ng-app="app"> <head> <link rel="stylesheet" href="style.css"> ...
3
votes
1answer
101 views

How does angular binding happen?

Below is my understanding of how binding happens in angularJS. Would be great if experts can provide feedback/comment.. <div ng-controller="ctrlA"> {{myvar}} {{anothervar}} </div> $...
1
vote
1answer
329 views

Angular $watch command selecting undefined variable

I have some HTML code in which I use angular to repeat radio inputs. I created a plunkr showing the functionality that I have right now. http://plnkr.co/edit/n5OZVlbiwToHsuvGN3QI The repeating code ...