使用ngModel无法正确获得离子输入值

时间:2017-10-29 18:22:48

标签: angular ionic-framework

我有一个离子输入,我需要检索值并通过按钮内的函数传递它。我尝试使用ngModel,但它无法正常工作,我应该怎么做呢?我做了一些研究并没有找到这个例子

  <ion-row>
    <ion-col col-6>
        <ion-input type="text" [(ngModel)]="nomeNervo" name="nomeNervo"></ion-input> 
    </ion-col>
    <ion-col col-6>
        <button ion-button (click)="pushRow(nomeNervo.value)" color="danger">
            Inserir
        </button> 
    </ion-col>  
    </ion-row> 

这是我的pushRow功能

  pushRow(nome: String){
   this.usuario.nomeNervo = nome;
   this.nervos.push(this.usuario);
                 }

nervos是任何类型的数组,通常是任何对象。

1 个答案:

答案 0 :(得分:1)

传递

<button ion-button (click)="pushRow(nomeNervo)" color="danger">
            Inserir
</button> 
相关问题