How to bind to model with Angular Material ?

后端 未结 7 1690
花落未央
花落未央 2020-12-09 03:19

Take a look at this Plunker: https://plnkr.co/edit/yu95hUrKlUh4Ttc5SwYD?p=preview

When I\'m using , I am able to modify the valu

相关标签:
7条回答
  • 2020-12-09 04:15
    public selectedVal: string;
    constructor() { }
    
    ngOnInit(){
      this.selectedVal ='option1';
    } 
    
    public onValChange(val: string) {
      this.selectedVal = val;
    }
    
     <mat-button-toggle-group #group="matButtonToggleGroup" [value]="selectedVal" (change)="onValChange(group.value)" >
      <mat-button-toggle value="option1">
        Option 1
      </mat-button-toggle>
      <mat-button-toggle value="option2">
        Option 2
      </mat-button-toggle>
    </mat-button-toggle-group>
    
    0 讨论(0)
提交回复
热议问题