In the following example, the
- first expression
{{ bar }}
is never updated, but the - second expression
{{ "" + bar }}
is updated:
e.g.
two
1588950994873
Why is this the case?
import { Component } from "@angular/core";
@Component({
selector: "my-app",
template: `
What is different and why?
<br />
{{ bar }} <br />
{{ "" + bar }} <br />
`
})
export class AppComponent {
value: string = "default";
bar: any = d => {
this.value = d;
};
ngOnInit() {
this.bar.valueOf = () => this.value;
this.bar("one");
setInterval(() => this.bar(Date.now() + ""), 1000);
this.bar("two");
}
}