Search code examples
angularangular-material2md-select

change function on md-select doesn't work? angular2


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


Solution

  • This should work:

    <md-select placeholder="Veileder {{i+1}}" 
      ngModel (ngModelChange)="updateSupervisorList(i)" name="veileder">