简体   繁体   中英

Ember StateManager does not find controller


I have tried my bit searching through StackOverflow for some answer, but could not locate. Refer below the following code snippet - Ember stateManager is unable to find the controller instance. Also the view code is not rendered also, please guide me as to the mistakes made.

Dashboard.stateManager = Ember.StateManager.create({
start: Ember.State.extend({
    controller: null,

    enter: function(manager) {
        this.controller = manager.get('indexController');
        this.setPath('view.controller', this.controller);
        console.log(this.controller);
    },

    view: Dashboard.MapView

})
});
Dashboard.initialize(Dashboard.stateManager);
Dashboard.stateManager.transitionTo('start');

The Dashboard.MapView is complex, it looks like

Dashboard.MapView = Ember.View.extend({
...
)};

Do I have to add something so that view gets executed? Why is statemanager unable to get 'indexController') - console output returns undefined in the console log line in this snippet, although Dashboard.IndexController is defined after the page is loaded and so is Dashboard.stateManager.

Please note that the app is single-page, so I have not defined routes at all, although IndexController is defined. Could this be a problem? But the app does not say 'route undefined' etc., but the page is blank? Is this the right way to define a StateManager for a single-page app without any routes other than "/"?

Thanks,
Paddy

如果您使用的是最新版本的Ember,我认为将stateManager的控制器替换为路由器的方法是:

manager.get('container').lookup('controller:index')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM