Controllers

Good! You made it all the way to the controllers tutorial. Now, let's walk through the concept of controllers.

We created an app/controllers/ directory for you. It contains two files: application.js and steroidsTutorial.js. From now on, let's not include any JavaScript in our views, okay?

Using view controllers

In the application wide layout app/views/layouts/steroidsTutorial.html there is a <script>-tag that automatically includes a controller for this resource (steroidsTutorial). Open app/controllers/steroidsTutorial.js and enable the top bar.

Application controllers

We also include application.js for every view. Open that application controller and see how we extracted the previous inlined WebView opening to more reusable code.