Set initially selected item in Select list in Angular2

后端 未结 7 1162
独厮守ぢ
独厮守ぢ 2020-12-07 23:59

I\'ve managed to get a Select list to bind with my model for the purpose of saving, but I cannot work out how to make Angular2 automatically select the correct option on the

7条回答
  •  遥遥无期
    2020-12-08 00:40

    The easiest way to solve this problem in Angular is to do:

    In Template:

    
    

    In your class:

    this.selectedObjectIndex = 1/0/your number wich item should be selected
    

提交回复
热议问题