2014-09-25 54 views
4

我想根據插座的存在顯示一些HTML塊。我試過這段代碼,但它不起作用。我錯過了什麼嗎?Emberjs:在某些條件下顯示插座

{{#if outlet}} 
    <table class="col-sm-9"> 
     some content 
    </table> 
    <table class="col-sm-3"> 
     {{outlet}} 
    </table> 
{{else}} 
    <table class="col-sm-12"> 
     some content 
    </table> 
{{/if}} 

編輯:

我的情況是,如果我在途中customers然後outlet是隱藏的,否則,如果我對路線customers.create然後outlet是表演。有什麼簡單的方法可以不用觸摸router.js文件嗎?

回答

0

您是否嘗試命名插座,然後呈現路由器中特定插座的內容。

請參閱http://emberjs.com/guides/routing/rendering-a-template/ 這樣的東西,這是在指南中提到的。

App.PostRoute = App.Route.extend({ 
    renderTemplate: function() { 
     this.render('favoritePost', { // the template to render 
     into: 'posts',    // the template to render into 
     outlet: 'posts',    // the name of the outlet in that template 
     controller: 'blogPost'  // the controller to use for the template 
    }); 
    this.render('comments', { 
    into: 'favoritePost', 
    outlet: 'comment', 
    controller: 'blogPost' 
    }); 
    } 
}); 
+1

查看我更新的問題。我以前沒有給出店名。順便說一下,有沒有簡單的方法來做到這一點,而無需觸摸'router.js'文件? – user3741665 2014-09-25 09:21:06

相關問題