2017-09-25 1 views
0

AlertController에서 입력을 얻으려고하고 있는데 Typescript에서 그 방법을 모르겠습니다.Ionic에서 AlertController의 입력 값을 얻는 방법

ionViewDidLoad(){ 
    // Presenting popup 
    this.alert.create({ 
     title:'Enter Details', 
     inputs:[{ 
      //phNo:'Enter Mob No. E.g.919090998302', 
      //placeholder: 'pNo', 
      name:'username', 
      placeholder: 'username' 

     },{ 
     name: 'number', 
     placeholder: 'PNo', 

     }], 

     buttons:[{ 
      text: 'Continue', 
      handler: username =>{ 
       if(typeof username!=null){ 
       this.name = username, 
       this.phNo = number 
       } 
      } 
     }] 
    }).present(); 

나는 최대한 빨리 버튼을 클릭으로 두 번째 입력 값을 얻을 필요가 있지만, 나는이,이에이 Cannot find name "number"을 말한다해야합니까 방법을 잘 모르겠어요.

답변

0

모든 입력 필드가 처리기로 전달됩니다. 하나의 필드 만 있으면 바로 액세스 할 수 있습니다. 그러나 많은 분야가 있기 때문에. handler params는 객체가됩니다

그래서 이것을 시도하십시오.

buttons:[{ 
      text: 'Continue', 
      handler: data =>{ 
       if(typeof username!=null){ 
       this.name = data.username, 
       this.phNo = data.number 
       } 
      } 
     }] 
+0

도움, 감사합니다. –

관련 문제