Angular2 select default first option

前端 未结 10 1568
半阙折子戏
半阙折子戏 2021-01-04 08:32

How do i select the first option in a select by default in angular 2 the following code don\'t seems to work.


     
     
 

2 ) If you are using a Form control you need just to set it like default value

 this.fgAddingProduct = new FormGroup({
        category: new FormControl(this.categories[0].id, [Validators.required]),
 });

And use a normal *ngFor


提交回复
热议问题