Questions tagged [angularjs-ng-change]

The ngChange allows to evaluate given expression when user changes the input.

Evaluate given expression when user changes the input. The expression is not evaluated when the value change is coming from the model.

Note, this directive requires ngModel to be present.

Usage

as attribute

<input
  ng-change="expression">
...
</input>

Parameters

ngChange – {expression} – Expression to evaluate upon change in input value.

References:

http://docs.angularjs.org/api/ng.directive:ngChange

265 questions
83
votes
7 answers

Angularjs dynamic ng-pattern validation

I have a form that if a checkbox is false enforces validation on a text input using the ng-required directive. If the checkbox is true, the field is hidden and the ng-required is set to false. The problem is that I also have a regex for validation…
Brian
  • 2,294
  • 6
  • 30
  • 51
54
votes
5 answers

How to implement an ng-change for a custom directive

I have a directive with a template like
My directive is declared as: return { templateUrl: '...', restrict: 'E', require: '^ngModel', scope: { …
htellez
  • 1,269
  • 2
  • 13
  • 25
50
votes
3 answers

How can I make angularjs ngChange handler be called only when user finishes typing

I have an input field, where I want to apply the variant of ngChange. The input field is sort of binding with an ajax call, when user changes the input, the server side will process the data, however, I don't wanna make the call too often. Say the…
9blue
  • 4,693
  • 9
  • 29
  • 43
43
votes
1 answer

When to use $watch or ng-change in Angularjs

When should I use angular $watch functions and when use ng-change angularjs directive? To me, they both can do the same. Are there any differences or usage patterns between them?
levi
  • 22,001
  • 7
  • 73
  • 74
37
votes
7 answers

How can I denote which input fields have changed in AngularJS

I'm working on an edit form (user.html) that PUTs data to an API, but I'd like to avoid PUTting all the data in the form. I'd like to PUT just the changed items. I've seen the use of dirty and pristine when working with forms, but this applies to…
brock
  • 2,302
  • 7
  • 27
  • 30
34
votes
6 answers

ng-change not working on a text input

I am new to angular js. In my code there is color picker initialized from a text field. User changes the value of color and I want that color to be reflected as a background of a text in a span. It is not working. What is missing? HTML:
Ashwin
  • 12,081
  • 22
  • 83
  • 117
33
votes
1 answer

how to call service method from ng-change of select in angularjs?

I am new to angular js. I am trying to call factory service method 'getScoreData' from ng-change of select, but not able to get it done. please help. Html code: The action() is executed when I manually type and change the input. However if I change the repair.test value by some other function programmatically, it…
13
votes
1 answer

AngularJS - Why is ng-change called before the model is updated?

Please see the following plnkr: http://plnkr.co/edit/KZwIBX?p=preview The first standard select works as expected(at least as far as I expected/anticipated), meaning that ng-change is called after the model is updated. But when I create a directive…
shuttj
  • 217
  • 1
  • 3
  • 11
12
votes
4 answers

Angular ng-change in input textbox with old value

For some reasons the ng-change on textbox is not working so i am using it; Using Angular-ui's ui-events. PROBLEM I want to call the function only if…
shrw
  • 1,719
  • 5
  • 27
  • 50
11
votes
4 answers

ngChange is called when model changed programmatically

I have a problem when angular's ng-change is called when model is changed programmatically. $scope.sendMessage = function() { $scope.message = "Message sent"; } $scope.confirmed = true; $scope.mySelectBox = $scope.selects[1];
divide by zero
  • 2,340
  • 5
  • 23
  • 34
11
votes
5 answers

Calling angularjs function on text input based on length

I have a text box. I would like to call a method inside controller only when user has filled in 'n' or more number of characters in the textbox. Can someone please give me pointers on how to approach this? Thanks
blue piranha
  • 3,706
  • 13
  • 57
  • 98
11
votes
4 answers

ng-checked and ng-change radio button not work together - angularjs

http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview js angular.module("sampleapp", []).controller('samplecontroller', function($scope,$rootScope) { $scope.radii = [ {id:.25, checked:false, name:"1/4 Mile"}, {id:.5, checked:false, name:"1/2…
9
votes
1 answer

Angularjs send value to database when leaving input field

Been looking around but i can't seem to find any good resources. Got an application where i want to update the data in the database once the user leaves the textbox/area etc., figured i could probably do this with the ngfocus event but i would also…
Dev edition
  • 133
  • 1
  • 2
  • 8
8
votes
2 answers

ngChange fires before value makes it out of isolate scope

//main controller angular.module('myApp') .controller('mainCtrl', function ($scope){ $scope.loadResults = function (){ console.log($scope.searchFilter); }; }); // directive angular.module('myApp') .directive('customSearch', function…
Rob Allsopp
  • 3,309
  • 5
  • 34
  • 53
1
2 3
17 18