The md-select directive will convert a Number to a String. This may result in unexpected $watch events triggering. For example,
$scope.number = 10;
$scope.$watch('number', function (newValue, oldeValue) {
// newValue = "10", oldValue = 10
if(newValue === oldeValue) {
return;
}
...
}
I suggest adding a type attribute to the md-select directive.
A proper support for 'ng-options' would probably solve this issue . There is an open ticket: https://github.com/angular/material/issues/1837.
Btw. Another side effect of this unintended conversion is that it triggers the form dirty flag.
Yes even I've faced this issue. Took some time to figure it out :smile:
I've faved the same issue. I get douplicated $watch triggers when ever the Selektion changes.
@daniel-nagy looking at your example - can you just use ng-value instead of value? Please notice that ng-change is not triggered at first load as expected (no change happened yet).
http://codepen.io/anon/pen/gavMoe
@ThomasBurleson initially created fix for this particular issue targeted for numbers with https://github.com/angular/material/commit/c9f2b9f9a96010c667bbe0e2937d54ed99e3057f but it was reverted with recommendation to use "ng-value" with https://github.com/angular/material/commit/b983c0d4575f6701cb327f29c75354dc31447c74 by @rschmukler
I believe unless "ng-value" is not an option for you guys, this issue can be closed?
@skosno I've been using ng-value without any issues. I believe this issue can be closed.
Most helpful comment
@daniel-nagy looking at your example - can you just use ng-value instead of value? Please notice that ng-change is not triggered at first load as expected (no change happened yet).
http://codepen.io/anon/pen/gavMoe
@ThomasBurleson initially created fix for this particular issue targeted for numbers with https://github.com/angular/material/commit/c9f2b9f9a96010c667bbe0e2937d54ed99e3057f but it was reverted with recommendation to use "ng-value" with https://github.com/angular/material/commit/b983c0d4575f6701cb327f29c75354dc31447c74 by @rschmukler
I believe unless "ng-value" is not an option for you guys, this issue can be closed?