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
Post a Comment