1

I want to know why the $dirty of the respective select elem is not changed when we change the ng-model value of it in js.

It's very basic (http://jsfiddle.net/HB7LU/2859/)

//HTML
<select name="mySelect" ng-model="value" ng-options="item for item in data"></select>

//JS
function MyCtrl($scope, $timeout) {
    $scope.value = "1";
    $scope.data = ["1", "2"];

    $timeout(function() {
        $scope.value = "2";
    }, 3000);    
}

Is this an angular bug? or $dirty is not suppose to be set?

farolfo
  • 388
  • 1
  • 4
  • 13

1 Answers1

3

Angular takes care of setting an input to $dirty for you when you change input's value manually.

To do it programmatically, use $setDirty();

You might also find this question useful.

Community
  • 1
  • 1
Dmitry Efimenko
  • 10,973
  • 7
  • 62
  • 79