My app.component.ts code:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
isDisabled = false;
ngOnInit(): void {
setTimeout(() => {
this.isDisabled = !this.isDisabled;
}, 2000);
}
}
My app.component.html code:
<input type="text" value="{{ isDisabled }}" disabled="{{ isDisabled }}" />
- The string interpolation for the
disabledattribute is evaluated to a truthy value (thus, making the input disabled from the get-go) - The string interpolation for the
valueattribute is evaluated tofalseinitially and just after the callback of thesetTimeoutis executed, thevalueattribute of the input istrue. (this is the behavior I expected for thedisabledattribute also)
Q: What's causing the difference in the way these two string interpolations work?