1

This is the html:

<md-select placeholder="Veileder {{i+1}}" (change)="updateSupervisorList(i)">
            <md-option *ngFor="let supervisor of displayedsupervisorList" >{{supervisor}}</md-option>
          </md-select>

This is the method in the .ts file (displayedsupervisorList is a string[] with names)

updateSupervisorList(i: number){
  console.log("updatesupervisorlist");
  this.displayedsupervisorList.splice(i,1);
}

When i choose an option nothing happens, it doesn't even go to the console.log

Jaroslaw K.
  • 5,224
  • 2
  • 39
  • 65
Kim Vu
  • 584
  • 9
  • 25

2 Answers2

4

This should work:

<md-select placeholder="Veileder {{i+1}}" 
  ngModel (ngModelChange)="updateSupervisorList(i)" name="veileder">
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
-1

Event change does not work, but you can use select method on md-option.

Here you can find documentation of md-select from angular-material. In a API REFERENCE tab describes all methods and parameters of md-select and md-option components

I hope that I helped you

Community
  • 1
  • 1
Jaroslaw K.
  • 5,224
  • 2
  • 39
  • 65
  • There's a `change` event - [Proof](https://github.com/angular/material2/blob/master/src/demo-app/select/select-demo.html#L38) – Kacper Polak Jan 26 '17 at 11:46