How to set default selected value of ion-option?

前端 未结 9 1191
悲&欢浪女
悲&欢浪女 2020-12-09 03:18

I\'m using Ionic v2 and I can not set the selected value when showing the page.


    

        
9条回答
  •  萌比男神i
    2020-12-09 03:28

      in html---->
    
         
            
              
                 {{q}}
                
            
          
    
    
    in ts---->
    //if u dont want any default selection
        this.defaultSelectQuestion = -1; 
    
    //if first element should be your default selection
      this.defaultSelectQuestion = 0;
    
    
    
    this.selectedQuestion=this.questionArray[this.defaultSelectQuestion]
    

提交回复
热议问题