Get current value when change select option - Angular2

前端 未结 6 1500
走了就别回头了
走了就别回头了 2021-01-31 08:00

I\'m writing an angular2 component and am facing this problem.

Description: I want to push an option value in select selector to its handler when the

6条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 08:50

    In angular 4, this worked for me

    template.html

    
    

    component.ts

    export class FilterComponent implements OnInit {
    
    selectedFilter:string;
       public filterTypes = [
       {value:'percentage', display:'percentage'},
      {value:'amount', display:'amount'},
      ];
    
       constructor() { 
       this.selectedFilter='percentage';
       }
    
       filterChanged(selectedValue:string){
       console.log('value is ',selectedValue);
    
       }
    
      ngOnInit() {
      }
    
      }
    

提交回复
热议问题