0
<ion-col size="4">
  <ion-input
    class="input-field"
    style="--padding-end: 20px; text-align: end;"        
    [(ngModel)]="discountPercent"
    (ngModelChange)="onDiscountPercentChange()"
    type="text"
    appDecimalPlaces="2">
    <p slot="end">%</p>
  </ion-input>
</ion-col>

Your text: [(ngModel)]="discountAmount"

I want to add this place format function getFormatedNumber(saleDecimals)

How can I solve this?

2
  • what exactly do you mean you want too add function? Commented Aug 21, 2024 at 9:29
  • stackoverflow.com/help/how-to-ask Commented Aug 21, 2024 at 13:43

1 Answer 1

0

First of all the question feels like incomplete but i assume you need to format the model value from input using your custom function

To do that, we can leverage the already called onDiscountPercentChange and with in that just run the getFormatedNumber(saleDecimals)

like in

onDiscountPercentChange(): void {
// run the format fn

this.getFormatedNumber(2);
}
Sign up to request clarification or add additional context in comments.

2 Comments

I have discount amount & discount percentage , i add gfN function in onDiscontChange(), both UI cannot change. getFormatedNumber(x) is changeable by ApI respond.
@Emerald, i still little confused on the objective here, what i understood is you want have a watcher on model change and when the user input is done you need to call and API for getFormatedNumber(x) and the server given the updated input for the input and then bind it here. is it correct ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.