How to set first option as selected where options build from loop in select box anular 4

后端 未结 3 1357
孤城傲影
孤城傲影 2021-01-28 06:41

I have worked on angular 4 project, In this project, I have a requirement to set the first option as selected where all options are created dynamically by loop. html code:

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-28 07:20

    Just in your ts, inside ngOnInit

    selectedServiceType : any;
    ngOnInit() {
      //make sure you have values for **`services`**
      this.selectedServiceType = services[0];
    }
    

提交回复
热议问题