Performance: Property binding with square brackets
This affects how efficiently Angular updates DOM element properties during rendering and user interaction.
<input [value]="username"><input value="{{username}}">| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Interpolation in attribute (value="{{username}}") | Updates attribute node | Triggers reflow on each change | Higher paint cost due to layout recalculation | [X] Bad |
| Property binding ([value]="username") | Updates DOM property directly | Single reflow per update | Lower paint cost, smoother rendering | [OK] Good |
[] do in Angular?src property of an <img> tag to a component variable imageUrl?export function MyComponent() {
const [isDisabled, setIsDisabled] = React.useState(true);
return <button [disabled]="isDisabled">Click me</button>;
}<input [value]=username>
isLoading. Which Angular template code correctly disables the button when isLoading is true and enables it otherwise?Pass the test and this pattern moves unknown