eble
eble

Reputation: 88

When routing in Ember 1.0.0 pre

I'm trying to create routing in my ember app with something like the following:

app= Ember.Application.create({
        ApplicationController: Ember.ObjectController.extend(),
        ApplicationView: Ember.View.extend(),

        Router: Ember.Router.extend({
            root: Ember.Route.extend({
                route: '/',

                aRoute: Ember.Route.extend({
                    route: '/routeA'
                }),
                bRoute: Ember.Route.extend({
                    route: '/routeB'
                })
            })
        })
});

app.initialize();

But when opening the page following error precents it self:

Uncaught Error: assertion failed: Could not find state for path  

When digging a little into the source code of ember, I the "hash" property of location is never set - Should be set when a hash event of some kind is triggered by the browser.

Am I on the right track and how do I solve this problem? ​

Upvotes: 1

Views: 500

Answers (1)

sly7_7
sly7_7

Reputation: 12011

Only leaf routes are routable, when entering '/', the router doesn't know where he has to go. I suggest you defining an index route, which only redirects to a leaf route. For example:

    Router: Ember.Router.extend({
        root: Ember.Route.extend({
            index: Ember.Route.extend({
                route: '/',
                redirectsTo: 'aRoute'
            }),

            aRoute: Ember.Route.extend({
                route: '/routeA'
            }),
            bRoute: Ember.Route.extend({
                route: '/routeB'
            })
        })
    })

Upvotes: 3

Related Questions