0
0
Angularframework~5 mins

Component template basics in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a component template in Angular?
A component template defines the HTML structure and layout that the component will display in the browser. It controls what the user sees and interacts with.
Click to reveal answer
beginner
How do you bind a component's property to display its value in the template?
You use interpolation with double curly braces, like {{ propertyName }}, to show the value of a component's property in the template.
Click to reveal answer
intermediate
What is the role of the @Component decorator's template or templateUrl property?
It tells Angular where to find the HTML template for the component, either inline with template or in a separate file with templateUrl.
Click to reveal answer
intermediate
How can you add a CSS class conditionally in an Angular template?
Use the <code>[class.className]</code> binding with a condition, for example: <code>&lt;div [class.active]="isActive"&gt;</code>. The class is added only if the condition is true.
Click to reveal answer
intermediate
What is the difference between interpolation and property binding in Angular templates?
Interpolation {{ }} is used to display string values inside HTML. Property binding [property] sets DOM element properties and can bind to non-string values like booleans or numbers.
Click to reveal answer
Which syntax is used to display a component's property value in the template?
A(propertyName)
B[propertyName]
C<propertyName>
D{{ propertyName }}
Where do you define the HTML structure for an Angular component?
AIn the service file
BIn the component's TypeScript class
CIn the component's template
DIn the module file
How do you link an external HTML file as a component's template?
AUsing template in @Component decorator
BUsing templateUrl in @Component decorator
CUsing styleUrls in @Component decorator
DUsing selector in @Component decorator
Which binding syntax adds or removes a CSS class based on a condition?
A[class.className]="condition"
B(class.className)="condition"
C{{ className }}
D[style.className]="condition"
What is the main difference between interpolation and property binding?
AInterpolation displays strings; property binding sets DOM properties
BInterpolation sets DOM properties; property binding displays strings
CBoth do the same thing
DInterpolation is for events; property binding is for styles
Explain how Angular component templates connect the component's data to what the user sees.
Think about how the component's properties appear on the screen.
You got /3 concepts.
    Describe how you can conditionally add a CSS class in an Angular template and why this might be useful.
    Consider how you might highlight or hide parts of the UI based on data.
    You got /3 concepts.