O'Reilly logo

AngularJS by Example by Chandermani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The app controller

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:

  1. Start the workout.
  2. Show the workout in progress and show the progress indicator.
  3. After the time elapses for an exercise, show the next exercise.
  4. 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required