Mohammed Aamier
Mohammed Aamier

Reputation: 188

How To Bind Interpolation Data To ngModel In angular 6

Please Check This Image It Contains My Output

Upvotes: 0

Views: 832

Answers (1)

DeborahK
DeborahK

Reputation: 60518

Welcome to stack overflow!

When using two-way binding, the binding both sets the value and gets the value.

You should not also use the value property. Try removing it.

Are you setting pending_amount anywhere else (other than the value property)?

If not, try adding the following to your component:

get pending_amount(): number {
  return paymentmodel.total_amount - paymentmodel.advance_amount;
}

This calculates the amount and provides it in a local pending_amount property. NOTE: This is separate from the paymentmodel's pending_amount property.

Then change your binding as follows:

<input type="number" 
       matInput placeholder="Pending Amount 
       [(ngModel)]='pending_amount'
       name="pendingamount">

This then binds to the local value.

Does that work for you?

Upvotes: 1

Related Questions