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 it (no matter what is the reason) My question is Is t
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(new_val, old_val) { console.log(new_val); //print new
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 to put it in a service and use the service from both co
I am trying to return multiple values from $scope.watch function. angular.module("MainApp") .directive('isActiveNav', [ '$location', function($location) { return { restrict: 'A', link: function($scope, el, attrs) { $scope.location = $location; $
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 example, are watchers what enable directives lik
I'm having a weird issue with a watcher function: $scope.$watch('builder.editItemForm.quantity',function(newValue,oldValue){ if(newValue !== oldValue){ if(newValue % 2 == 0){ builder.editItemForm.quantity = newValue; } else { builder.editItemForm.qua
How to use an isolated scope property properly? I have a directive, that is called from a page controller, with an attribute item passed to it, e.g. <my-directive item="myItem"></my-directive>, containing an id. The code below will n
Not sure if I made myself clear on my question but what I really want is to update the min-width with ng-style for each <li> within an ng-repeat to equal the percentage of 100 / array.length. My first solution is simply: <li ng-style="{'min-
I've a button in my angular app that will add an input element to my app dynamically. I want to attach model to this element and put it to watch group for tracking any changes. If user add multiple input elements, I want to add all those models in wa
Simple question here. I have this watch: // Watch our model $scope.$watch(function () { // Watch our team name return self.model.team.data.name; }, function (name) { console.log(name); // if we have a name if (name) { // Store our model in the sessio
I have 2 selects where I need to choose a range of years. The year of the second select has to be greater or equal than the first one. So if I select a year in the first select, the second select should change and show just the years greater or equal
please pay attention this is the opposite of 99% of the related questions on stackoverflow. Mi problem is: I have a dependent select, when the 'Master' select changes, the 'Slave' view gets updated but NOT it's model. WEIRD. Example code: <!DOCTYPE h
I have created an application is angularjs in which i am having a directive, i am ahving a watch within the directive to trigger some methods within the directive when there is a change in $rootScope variable, but the problem is when the $rootScope.n
For watching an object scope variable, is $scope.$watch with objectEquality set to true OR $scope.$watchCollection better? For a $scope object variable (like 15 attributes, some nested 2 levels deep) updated with input elements and ng-model in the vi