Recall & Review
beginner
What is the purpose of type annotations in Angular components?
Type annotations help Angular and TypeScript understand what kind of data a variable or property holds. This makes the code safer and easier to read, like labeling boxes so you know what's inside.
Click to reveal answer
beginner
How do you add a type annotation to a component property in Angular?
You add a colon and the type after the property name. For example:
name: string; means the property name must hold text.Click to reveal answer
intermediate
Why is it helpful to use type annotations for @Input properties?
Type annotations tell Angular what type of data the component expects from its parent. This helps catch mistakes early, like sending a number when text is expected.
Click to reveal answer
intermediate
What type would you use to annotate a property that can hold either a number or null?
You use a union type like
number | null. This means the property can be a number or it can be empty (null).Click to reveal answer
beginner
How do type annotations improve teamwork in Angular projects?
They make the code clearer for everyone. When types are clear, teammates understand what data is expected without guessing, reducing bugs and confusion.
Click to reveal answer
Which syntax correctly adds a type annotation for a string property called 'title' in an Angular component?
✗ Incorrect
In TypeScript, the correct syntax is
propertyName: type; so title: string; is correct.What does the type annotation
number | null mean for a component property?✗ Incorrect
The union type
number | null means the property can hold either a number or null.Why should you add type annotations to @Input properties in Angular?
✗ Incorrect
Type annotations on @Input properties help Angular and developers know what data type the component expects.
Which of these is NOT a benefit of using type annotations in Angular components?
✗ Incorrect
Type annotations help catch errors before running code but do not fix bugs automatically at runtime.
How do you annotate a property that holds a list of strings in an Angular component?
✗ Incorrect
The correct TypeScript syntax for an array of strings is
string[].Explain how type annotations help improve code safety and clarity in Angular components.
Think about how labeling things helps avoid mistakes.
You got /4 concepts.
Describe how to add type annotations to component properties and @Input properties in Angular.
Remember the syntax: propertyName: type;
You got /4 concepts.