Recall & Review
beginner
What is an enum in Angular applications?
An enum is a special TypeScript feature used to define a set of named constants. It helps organize related values with friendly names, making code easier to read and maintain.
Click to reveal answer
beginner
How do you declare a numeric enum in Angular (TypeScript)?
You declare it using the
enum keyword followed by names and optional values. Example:<br>enum Color { Red, Green, Blue } Here, Red=0, Green=1, Blue=2 by default.Click to reveal answer
intermediate
What is a string enum and why use it in Angular?
A string enum assigns string values to each name. It improves clarity when values are logged or sent over the network. Example:<br>
enum Direction { Up = 'UP', Down = 'DOWN' }Click to reveal answer
intermediate
How can enums improve Angular component code?
Enums help by replacing magic numbers or strings with meaningful names. This reduces errors and makes the code easier to understand and maintain, especially for status codes or modes.
Click to reveal answer
intermediate
Can you use enums in Angular templates directly?
No, Angular templates cannot access enums directly. You need to expose the enum to the component class and then bind it to the template for use.Click to reveal answer
What keyword is used to declare an enum in Angular (TypeScript)?
✗ Incorrect
The
enum keyword declares an enum in TypeScript, which Angular uses.What is the default value of the first member in a numeric enum?
✗ Incorrect
By default, the first member of a numeric enum is assigned the value 0.
Why might you choose a string enum over a numeric enum?
✗ Incorrect
String enums make code clearer and easier to debug because values are descriptive strings.
How do you make an enum accessible in an Angular template?
✗ Incorrect
You expose the enum in the component class, then bind it in the template.
Which of these is NOT a benefit of using enums in Angular?
✗ Incorrect
Enum values are fixed at compile time and cannot be changed dynamically at runtime.
Explain what enums are and how they help in Angular applications.
Think about how enums replace unclear numbers or strings with clear names.
You got /3 concepts.
Describe how to use enums in Angular templates and why direct use is not possible.
Consider the separation between TypeScript code and Angular template syntax.
You got /3 concepts.