Redirect from index to another route and force model ()

I want to send the user a message /articles when he reaches / . Unfortunately, the /articles model() function will not execute because it is not a page refresh:

 App.IndexRoute = Em.Route.extend redirect: -> @transitionTo "articles" 

How can this be achieved?

+7
source share
1 answer

I cannot tell the rest of your installation, but that is how I achieve it.

 window.App = Ember.Application.create(); App.Store = DS.Store.extend({ adapter: DS.FixtureAdapter }); App.Router.map(function() { this.resource('articles', function() { this.resource('article', {path: ':article_id'}); }); }); App.Article = DS.Model.extend({ title: DS.attr('string') }); App.Article.FIXTURES = [{ id: 1, title: 'blah' }, { id: 2, title: 'more blah' }]; App.IndexRoute = Ember.Route.extend({ redirect: function() { this.transitionTo('articles'); } }); App.ArticlesRoute = Ember.Route.extend({ model: function() { return App.Article.find(); } }); 

working example: http://jsbin.com/imidiq/2/

+8
source

All Articles