Components: md-select change event not firing

Created on 22 Dec 2016  路  4Comments  路  Source: angular/components

Bug, feature request, or proposal:

Bug

What is the expected behavior?

After the user selects a value from the select box, the change event must be fired.

What is the current behavior?

None. The change function asociated with the event is never executed.

What are the steps to reproduce?

Plunker: http://plnkr.co/edit/sSprD4?p=preview

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, browsers are affected?

"@angular/common": "2.3.1",
"@angular/material": "^2.0.0-alpha.11-3",

Is there anything else we should know?

Most helpful comment

You could use (ngModelChange) instead of (change). This works for me:
<md-select *ngIf="cultivos" placeholder="Cultivo" formControlName="idCultivo" (ngModelChange)="cultivoChange()" class="input-form">
<md-option *ngFor="let cultivo of cultivos" [value]="cultivo.idCultivo">{{cultivo.usoSigpac}} - {{cultivo.fruto}} - {{cultivo.variedad}}</md-option>
</md-select>

All 4 comments

You could use (ngModelChange) instead of (change). This works for me:
<md-select *ngIf="cultivos" placeholder="Cultivo" formControlName="idCultivo" (ngModelChange)="cultivoChange()" class="input-form">
<md-option *ngFor="let cultivo of cultivos" [value]="cultivo.idCultivo">{{cultivo.usoSigpac}} - {{cultivo.fruto}} - {{cultivo.variedad}}</md-option>
</md-select>

@Dgiulian
Para que el evento (change)="onChange($event)" funcione debes de importar MdSelectChange

import { MdSelectChange } from '@angular/material';

//Evento (change)
onChangeSelect(event: MdSelectChange) {
console.log(event.value)
}

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kara picture kara  路  3Comments

3mp3ri0r picture 3mp3ri0r  路  3Comments

alanpurple picture alanpurple  路  3Comments

theunreal picture theunreal  路  3Comments

dzrust picture dzrust  路  3Comments