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

State transitions in controllers

In Chapter 3, Routing and State Management, we learned that routes can transition the state of an application into other routes by invoking their transitionTo method, as shown in the following code:

App.IndexRoute = Ember.Route.extend({
  redirect: function(){
    this.transintionTo('posts');
  }
});

Likewise, controllers also have this capability through the use of the provided transitionToRoute method. For example, we can change states in a controller's action handler as:

App.PostsNewController = Ember.ObjectController.extend({
  actions: {
    cancel: function(post){
      this.transitionToRoute('posts');
    }
  }
});

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