Explain it simply
Property Binding [ ], in plain language
Property Binding [ ] lets you bind an HTML element's property (e.g., src , disabled ) to data in the component. Data flows one-way, from the component to the template.
Problem → Why → Solution
The problem — why this concept matters
Treating disabled="false" as a false property is incorrect; the presence of the attribute can still disable the control.
A common mistake
One happy-path result does not prove the feature works; empty, loading, error, and cleanup behavior need explicit tests.
Core concept — understand how it works
Property binding [target]="expression" sends a typed value to a DOM, component, or directive property rather than writing a string attribute. Attributes describe initial markup, while properties represent live runtime state, which matters for disabled, value, class, and similar targets. With child inputs, the parent owns the data and should use a clear mutation policy.
- input and state
- component and template
- rendered Angular UI
Explain the core concept and Angular data flow of Property Binding [ ]
Core syntax or pattern
<img [src]="imageUrl">
<button [disabled]="isButtonDisabled">Click Me</button>
// component.ts
export class MyComponent {
imageUrl = 'path/to/image.jpg';
isButtonDisabled = true;
}Property binding [target]="expression" sends a typed value to a DOM, component, or directive property rather than writing a string attribute. Attributes describe initial markup, while properties represent live runtime state, which matters for disabled, value, class, and similar targets. With child inputs, the parent owns the data and should use a clear mutation policy.
Read the code step by step
- input and state
<img [src]="imageUrl">Property Binding [ ] lets you bind an HTML element's property (e.g., src , disabled ) to data in the component. Data flows one-way, from the component to the template.
- component and template
export class MyComponent {Property binding [target]="expression" sends a typed value to a DOM, component, or directive property rather than writing a string attribute. Attributes describe initial markup, while properties represent live runtime state, which matters for disabled, value, class, and similar targets. With child inputs, the parent owns the data and should use a clear mutation policy.
- rendered Angular UI
}Bind a button's disabled state, an image source, and a child object input, verifying that Boolean and object values are not stringified.
- input and state
- component and template
- rendered Angular UI
Success
Explain the core concept and Angular data flow of Property Binding [ ]
Failure
Treating disabled="false" as a false property is incorrect; the presence of the attribute can still disable the control.
Property Binding [ ] lets you bind an HTML element's property (e.g., src, disabled) to data in the component. Data flows one-way, from the component to the template.
<img [src]="imageUrl">
<button [disabled]="isButtonDisabled">Click Me</button>
// component.ts
export class MyComponent {
imageUrl = 'path/to/image.jpg';
isButtonDisabled = true;
}(An image will appear, and the button will be disabled)Real-world usage
How to apply it in a real project
Bind a button's disabled state, an image source, and a child object input, verifying that Boolean and object values are not stringified.
Mini challenge
Build it yourself
Rebuild the Property Binding [ ] example without copying it. Add two normal states, one edge case, and one failure state, and write the expected UI and state transition before running it.
- Rebuild the example without copying it
- Test a normal input and an edge case
- Predict the compiler or output result before running it
<img [src]="imageUrl">
<button [disabled]="isButtonDisabled">Click Me</button>
// component.ts
export class MyComponent {
imageUrl = 'path/to/image.jpg';
isButtonDisabled = true;
}Expected: Explain the core concept and Angular data flow of Property Binding [ ]
Show hint
Bind a button's disabled state, an image source, and a child object input, verifying that Boolean and object values are not stringified.
Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- input and state → component and template → rendered Angular UI
- Property binding [target]="expression" sends a typed value to a DOM, component, or directive property rather than writing a string attribute. Attributes describe initial markup, while properties represent live runtime state, which matters for disabled, value, class, and similar targets. With child inputs, the parent owns the data and should use a clear mutation policy.
- Treating disabled="false" as a false property is incorrect; the presence of the attribute can still disable the control.
- Bind a button's disabled state, an image source, and a child object input, verifying that Boolean and object values are not stringified.
Angular — Templates — Angular