I need to use ng2-currency-mask input mask with Ionic 3
app. They have given a fix for input focus issue which is in the Ionic app. I cannot understand what I have to do here. Can you tell me how to use it?
child component
.html
<div>
<input currencyMask type="tel" [(ngModel)]="value" [id]="'yourInputId' + index"
(focus)="scrollTo(index)" />
</div>
.ts
import { Content } from 'ionic-angular';
export class...
@ViewChild(Content) content: Content;
scrollTo(index) {
let yOffset = document.getElementById('yourInputId' + index).offsetTop;
this.content.scrollTo(0, yOffset + 20);
}
Can you tell me what was this [id]="'yourInputId' + index"
? How can I set that on my Ionic app?
You can read more about it here.
Update:
I have tried like this.But compile time error on template due to index
. I don't have any for loops
here.
<input currencyMask type="tel" [ngModel]="data?.budget"
[options]="{ prefix: '', thousands: ',', decimal: '' }"
formControlName="budget"
ngModelChange)="data.budget=$event;calculateContingency()"
[id]="'yourInputId' + index" (focus)="scrollTo(index)"/>
My component structure:
parent.html
<ion-content class="project">
<ion-grid>
<ion-row class="details">
<project [data]="data"></project>// above code is in this child componet
</ion-row>
</ion-grid>
</ion-content>