O'Reilly logo

Instant Ember.js Application Development How-to by Marc Bodmer

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

Creating an Ember controller (Simple)

A controller is an object capable of storing the application state. Application views connect to controllers and translate the current state of the controller into HTML. Another way of thinking of controllers is that they act as a direct representation of models for your views and can send CRUD commands to the models on behalf of the views.

How to do it...

We can now create a controller for a part of our application.

  1. Add the following controller into application.js located in the controllers folder:
    MovieTracker.moviesController = Ember.ArrayController.create({ content: [], init: function(){ this._super(); var list = [ MovieTracker.Movie.create({ title: 'Movie 1', rating: 4 }), MovieTracker.Movie.create({ title: ...

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