Refactor hard-coded values to use an enumeration.
- Open the app.component.ts file.
- Define an
Episodeproperty within the
AppComponentclass. This enables the template to reference the enum.
- Open the app.component.html template file.
- Update the
NgSwitchCasestructural directives to use the
Episodeenum members in place of the hard-coded integer values.
- In most instances, properties within a class are lowerCamelCase strings. Here, we are using an UpperCamelCase string, namely
Episode. Your preferences may vary here, but I am using the upper camel-case string because we are using an enum, which like a class name, is commonly uppercased.
- The primary advantage here is that we are no longer hard-coding "magic" integer values in our template. Rather, we are explicitly referring to the values of each member within the