2014-05-21 38 views
0

對不起,我的英文不夠好描述更復雜的東西,但我會盡我所能。Ember.js - outlet的默認內容

我要瘋了。我只想爲Ember.js中的插座定義默認內容,但我找不到任何解決方案。我發現的例子使用url匹配,但在我的情況下沒有特殊的URL來識別默認模板。

讓我們來看看:

application <-- the application frame, contains an outlet 
/   <-- the index, contains also an outlet 
/foobar  <-- some other stuff, which will be rendered in the outlet of index, if the URL is set => that works! 

我的問題是渲染默認模板指數的出口,如果URL == '/'

有什麼建議?

+0

默認你的意思是什麼? '/'通常指的是應用程序+索引模板。你有一個bin示例來演示你的問題嗎? – blessenm

回答

0

我想我明白你在找什麼。

在您的模板中,創建一個ID設置爲「index」的腳本。該腳本中的任何內容都應在您的「默認」網址加載時顯示。

<script type="text/x-handlebars" id="index"> 
    Welcome to my Ember.js site! 
</script> 

並確保在您的腳本ID與「應用程序」ID'd你有一個出口設置。

<script type="text/x-handlebars" id="application"> 
    <div> 
    Testing 1..2..3... 
    </div> 
    <div> 
     {{outlet}} 
    </div> 
</script> 

希望這會有所幫助。