Fixing the Workout and Exercise components

Once we have fixed the WorkoutBuilderService and the WorkoutResolver, there are actually no further fixes needed in the WorkoutComponent. All the work to handle the Observables has been done further downstream and all we need to do at this stage is subscribe to the route data and retrieve the workout as we have already been doing:

  ngOnInit() {
this.sub = this.route.data
.subscribe(
(data: { workout: WorkoutPlan }) => {
this.workout = data.workout;
}
);
}

To test the implementation, uncomment the following highlighted code contained in the onSelect method within workouts.component.ts:

  onSelect(workout: WorkoutPlan) {
this.router.navigate( ['./builder/workout', workout.name] );
}

Then click on any existing workout, such as 7 Minute Workout, from the list of workouts displayed at /builder/workouts/. The workout data should load successfully.

The ExerciseBuilderService and ExerciseResolver also need fixing. Checkpoint 5.2 contains those fixes. You can copy those files or do it yourself and compare the implementation. And don't forget to uncomment the code in the onSelect method in exercises.component.ts.

Checkpoint 5.2 in the GitHub repository contains the working implementation for what we have covered thus far. If you are not using Git, download the snapshot of Checkpoint 5.2 (a ZIP file) from the following GitHub location: https://github.com/chandermani/angular6byexample/tree/checkpoint5.2. Refer to the README.md file in the trainer folder when setting up the snapshot for the first time.

It is now time to fix, create, and update scenarios for the exercises and workouts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.5.86