Exercise Goals

Refactor hard-coded values to use an enumeration.

Tasks

  1. Open the app.component.ts file.
  2. Define an Episode property within the AppComponent class. This enables the template to reference the enum.
  3. Open the app.component.html template file.
  4. Update the NgSwitchCase structural directives to use the Episode enum members in place of the hard-coded integer values.

Exercise

Exercise Problem

Notes

  • 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 Episode enumeration.