Material: md-select: ng-change issue

Created on 19 Feb 2015  路  21Comments  路  Source: angular/material

md-select does not support ng-change event.
According to angular select it does. In order to listen to change events $watch has to be implemented which is not very performant.

http://plnkr.co/edit/m4PMSuVnkhwxrFijcOsb?p=preview

fixed

Most helpful comment

I think this should be documented.

Currently it is not : https://material.angularjs.org/#/api/material.components.select/directive/mdSelect

All 21 comments

This is because the md-select-menu actually creates a new ng-model, it doesn't share the md-select's ng-model.

@rschmukler we could manually get/set the ngModelController from the <md-select> element and set it to element.data() on the md-select-menu.

fixed in f4ce10eea6590ac431b7b15c44242b76219e1f7f

This doesn't seem to be working:

                        md-select.no-margin-top(ng-model="player.title",ng-change="changeTitle()")
                            md-option(ng-value="title",ng-repeat="title in titles") {{title}}

Does not seem to be calling ng-change ever.

Ah, that commit does not appear to have made it into 0.8.0. Can we get a quick maintenance release for that fix?

We will discuss the possibility of a maintenance release. Closing this issue since it's resolved.

Is this in 0.8.3?

@axelson yes.

Thanks! It turns out I just had a syntax error...

I think this should be documented.

Currently it is not : https://material.angularjs.org/#/api/material.components.select/directive/mdSelect

@Splaktar Are you sure this has been resolved in 0.8.3 release? it is not working for me!

Works for me in 0.8.3

Ignore the above reference... I mistyped. If anyone is having issues with it in 0.8.3 please open a new issue with an example codepen / plunker so we can debug

can someone share an example? It doesn't work for me :|

doesn't work for me either!
version: 1.1.0

not working for me either

Not working :/

It is a little hacky, but this is working for me:

https://material.angularjs.org/latest/api/directive/mdSelect

md-on-close

<md-select ng-model="model[field]" md-on-close="debounceSave()">

It isn't great, because now it runs even if it doesn't change! But it does work!

not working for me. v1.1.4

Doesn't work for me as well. As for md-on-close it triggers function always, regardless model changed or not. If user doesn't select anything function will be triggered anyway.

Here's a demo of ng-change working with md-select in 1.1.7. If you are having problems with this, please submit a new issue with a CodePen reproduction.

@david-gang you are correct that this is missing from the docs. Opened https://github.com/angular/material/pull/11152 to add it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriseyhorn picture chriseyhorn  路  3Comments

bobber205 picture bobber205  路  3Comments

WebTechnolog picture WebTechnolog  路  3Comments

reggiepangilinan picture reggiepangilinan  路  3Comments

LeoLozes picture LeoLozes  路  3Comments