2014-09-22 13 views
1

我在先進的道歉,如果這是一個簡單的錯誤或我不知道的東西很明顯。我查看了其他用戶在StackOverflow上的問題,但仍然無法讓我的工作。我究竟做錯了什麼?我正在網上學習一個教程,我的代碼看起來與我的教師完全相同。新來Ember.js,我可以使所有的模板,除了我的根應用程序模板

我的問題是,我可以通過在我的瀏覽器的URL中輸入我的路由來讓Ember呈現「about」,「about/team」,「contact」的模板,但只要我添加一個句柄模板到我的應用程序(我計劃然後使用無序列表導航到這些路線/模板)它不會呈現我的應用程序模板。

這是我的代碼。

<html> 
<head> 
    <title>Let's Learn Ember.js</title> 

    <script src="js/libs/jquery-1.10.2.js"></script> 
    <script src="js/libs/handlebars-1.0.0.js"></script> 
    <script src="js/libs/ember.js"></script> 

<script> 
    window.App = Ember.Application.create(); 

    App.Router.map(function(){ 
    this.resource("about", function(){ 
     this.route("team") 
    }); 
    this.route("contact"); 

    }); 
</script> 
</head> 
<body> 
    <script type="text/x-handlebars" data-template-name="application"> 

    <nav> 
    <ul> 
     <li>{{#linkTo "index"}}Home{{/linkTo}}</li> 
     <li>{{#linkTo "about"}}About{{/linkTo}}</li> 
     <ul> 
      <li>{{#linkTo "about.team"}Team{{/linkTo}}</li> 
     </ul> 
     </li> 
     <li>{{#linkTo "contact"}Contact{{/linkTo}}</li> 
    </ul> 
    </nav> 

    {{outlet}} 
    </script> 


    <script type="text/x-handlebars" data-template-name="index"> 
    <h1>Welcome to Ember.js </h1> 
    </script> 

    <script type="text/x-handlebars" data-template-name="about"> 
    <h1>About Page</h1> 
    {{outlet}} 
    </script> 

    <script type="text/x-handlebars" data-template-name="about/team"> 
    <h2>here is our team!</h2> 
    </script> 

    <script type="text/x-handlebars" data-template-name="contact"> 
    <h1>Please contact us!</h1> 
    </script> 

</body> 
</html> 

編輯 原來,這是因爲我並沒有結束我的車把我的雙大括號與我聯繫,以「團隊」和「接觸。

對不起,愚蠢的問題。

回答

0

你缺少一些右括號鏈接到的。這是與修訂

<li>{{#linkTo "about.team"}}Team{{/linkTo}}</li> 
    </ul> 
    </li> 
    <li>{{#linkTo "contact"}}Contact{{/linkTo}}</li> 

容易的事情錯過!強烈建議讓您的控制檯在你的瀏覽器中,它會捕獲解析錯誤。

+0

是啊,這是!現在我感到很蠢。謝謝你指出,雖然。我很感激。 – 2014-09-22 20:39:46

相關問題