O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

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

Providing controllers with models

Before we proceed, let's recap and see how data is loaded and stored in controllers. Most of the applications we'll build will communicate with REST endpoints, and therefore, Ember.js comes with features that make the creation of such applications trivial. In Chapter 3, Routing and State Management, we learned that data can be loaded from the server in an asynchronous fashion via a route handler's model hook. For example, let's define a blog post route that loads a particular blog post from our server. First, we'll define our application's router as:

App.Router.map(function(){
  this.resource('posts', function(){
  });
  this.resource('post', {path: '/post/:post_id'});
});

We just defined a post resource that will handle ...

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