javascript - ionic Bind maxlength dynamically ionic2 -


my requirement bind maxlength ion-input. have tried using interpolation concept bind.

my html

 <ion-list >     <ion-item *ngfor=" let of arr_label">       <ion-label floating>{{a.lblname}}</ion-label>       <ion-input maxlength={{a.maxlent}}   [(ngmodel)]="a.val" type="text"></ion-input> </ion-item> 

.ts

arr_label:any[]=[]; this.arr_label.push({maxlent:10}); 

is there missing... quite appreciable.

you can bind attributes in 3 different ways

bind directly it, if it's native attribute:

<ion-input [maxlength]="a.maxlent" [(ngmodel)]="a.val" type="text"></ion-input> 

bind attr prefix - works on custom , native attributes:

<ion-input [attr.maxlength]="a.maxlent" [(ngmodel)]="a.val" type="text"></ion-input> 

or set value interpolated string value of variable:

<ion-input maxlength="{{a.maxlent}}" [(ngmodel)]="a.val" type="text"></ion-input> 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -