无法在ts文件中获取默认选择值

时间:2018-11-26 09:27:25

标签: angular ionic3

如何获取打字稿中动态选择的输入的值

<ion-list *ngFor="let specs of spec;let i = index">
   <ion-item>
      <ion-label stacked>
        {{specs.title}}
     </ion-label>
     <ion-input type="text" value="{{specs.t_value}}" 
                [(ngModel)]="specification[i]" name="specification"></ion-input>
     </ion-item>
 </ion-list>

1 个答案:

答案 0 :(得分:0)

为动态字段尝试类似的操作

   <form #myForm="ngForm">
         <ion-list *ngFor="let specs of spec;let i = index">
               <ion-item>
                  <ion-label stacked>
                    {{specs.title}}
                 </ion-label>
                 <ion-input type="text"[(ngModel)]="specs.t_value"   #value="ngModel" name="specification[{{i}}]"></ion-input>
                 </ion-item>
             </ion-list>
<button ion-button block   color="primary" (click)="insert(myForm)">Save</button>
</form>