EmberJs: how to use connectOutlet

2019-08-30 06:10发布

I've created a simple test in which I try to use connectOutlet. However, not much is rendered. Here is my test code: http://jsfiddle.net/jeanluca/53dpA/

Just to summarize the application. I think the problems is inside the following code

App.Router.map(function(match) {
    match('/').to('index');
});     

App.IndexRoute = Em.Route.extend({
    connectOutlets: function(router) {
        router.get('applicationController').connectOutlet('sidebar', 'navigation');
        router.get('applicationController').connectOutlet('content');
    }       
});

Any suggestions what is wrong with this code ?

Also, in almost any example code I find on the web, I see that the App.Router is defined

App.Router = Em.Router.extend({
        enableLogging: true,

        root: Em.Route.extend({

            index: Em.Route.extend({
                route: '/',
                connectOutlets: function(router) {   
    .... etc ....

Because with ember-latest App.Router is already defined, I assume this is the old way of defining the Router ?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-30 06:26

I see in your fiddle that you are using pre-2. The newest version is pre-4, so I suggest you use that. http://emberjs.com/guides/ is up to date with pre-4.

I have created a fiddle and used your code as a starting point and ended up with what I think is what you tried to accomplish: http://jsfiddle.net/Energiz0r/9Xasr/4/

Basically the connectOutlet is replaced with

this.render('content', {into: 'index', outlet:'content');

And there are alot of other changes in the new route API. Again go through the guides at http://emberjs.com/guides/ to get the full understanding of it all.

Hope this helps!

查看更多
登录 后发表回答