Ionic binding collision with ngModel


#1

ionic 2 binding collision with ngModel:
i want the name of the iion-input to bing to an array, and the input text also bind to other att.

how should i do it?

 <ion-input type="text" [name]="this.formAtt[0]" [(ngModel)]="this.formAtt[0]">{{this.temp }}</ion-input>
and if i do this, the name won't bind:
 <ion-input type="text" [name]="this.formAtt[0]" [(ngModel)]="this.temp"></ion-input>

thanks


#2

this in templates isn’t needed, but I can’t reproduce your problem:

fruits = ['apple', 'banana', 'cherry'];
fruit = 'banana';
<ion-input [name]="fruits[0]" [(ngModel)]="fruit"></ion-input>

…results in:

<input class="text-input text-input-md" ng-reflect-klass="text-input" ng-reflect-ng-class="text-input-md" type="text" autocomplete="off" autocorrect="off" placeholder="" ng-reflect-name="apple" ng-reflect-model="banana">

…which looks like what one would expect.


#3

hi,
it crashes with exception:
the code:
temp=“abc123”;

<ion-input type="text" [name]="temp" [(ngModel)]="this.dataSegmentInputs[this.formAtt[2]]"></ion-input>


#4

i changed
temp=“abc123”;
to
temp=‘abc123’;

if you have any idea why single quote workd and double dont…please tell me.

anyhow, thanks for the solution!