I have a component as follows:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app',
template: `
<div>
<div>value of a :
<input [(ngModel)]="a" />
</div>
<div>value of b :
<input [(ngModel)]="b" />
</div>
<div>
Value of a = {{a}}
<br> Value of b = {{b}}
<br> Sum instantaneous {{calc(a+b)}}
</div>
</div>
`
})
export class AppComponent implements OnInit {
a: string = "";
b: string = "";
constructor() { }
ngOnInit() {
}
calc() {
console.log('test');
return (+this.a + +this.b);
}
}
Every time, I modify (say, key press) anything in textboxes or even just
focusing/defocusing textboxes, the 'calc' function gets executed twice.
What am I missing here or how can I get the function execute once (instead of
twice).
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.