To implement the controller, we need to outline the behavior of the application. What we are going to do in 7 Minute Workout app is:
Start the workout.
Show the workout in progress and show the progress indicator.
After the time elapses for an exercise, show the next exercise.
Repeat this process till all exercises are over.
This gives us a fair idea about the controller behavior, so let's start with the implementation.
Add a new JavaScript file workout.js
to the 7MinWorkout
folder. All code detailed in the line later goes into this file until stated otherwise.
We are going to use the Module API to declare our controller and this is how it looks:
angular.module('7minWorkout').controller('WorkoutController', function($scope){ });
Here, we retrieve the 7minWorkout
module that we created earlier in app.js
(see the Adding app modules section) using the angular.module('7minWorkout')
method and then we call the controller method on the module to register our 7minWorkout
controller.
The...