简体   繁体   English

Ember.js无法显示自己的模板

[英]Ember.js can't display own template

I have just started to follow some tutorials and suddenly got a problem with displaying a template. 我刚刚开始遵循一些教程,突然在显示模板时遇到问题。 I can't display any template other than the default one. 除了默认模板外,我无法显示其他模板。

The following code is placed just after the default handlebar (which is doing well) in the index.html->body: 将以下代码放置在index.html-> body中默认把手(运行良好)之后:

<script type="text/x-handlebars" data-template-name='myTemplateName'>
    <h2>Why can not I just be shown?</h2>
</script>

I had created a view file which is referenced in the index.html correctly: 我已经创建了一个在index.html中正确引用的视图文件:

MovieTracker.ApplicationView = Ember.View.extend({
  templateName: 'application'
});

MovieTracker.ApplicationView = Ember.View.extend({
  templateName: 'myTemplateName'
});

The problem is that I'm not getting any errors (checked with firebug console), but the content of 'myTemplateName' isn't shown. 问题是我没有收到任何错误(已通过Firebug控制台检查),但是未显示“ myTemplateName”的内容。

Why can't I add my own templates, while the default one works fine? 为什么我不能添加自己的模板,而默认模板可以正常工作?

I'll appreciate a lot your help, It's very important to me, and I searched all over the internet without finding anything. 非常感谢您的帮助,这对我来说非常重要,我在Internet上进行搜索时一无所获。

Has your application template got an {{outlet}} ? 您的应用程序模板有{{outlet}}吗? Where are you linking to your template? 您在哪里链接到模板?

{{#link-to 'myTemplateName'}}Your Template{{/link-to}}

Have you set up a route? 您设置路线了吗?

App.Router.map(function() {
  this.route("myTemplateName", { path: "/myTemplateName" });
});

Once the handlebars link to is clicked it should populate your {{outlet}} in your main template with the correct template. 单击指向车把的链接后,应使用正确的模板填充主模板中的{{outlet}}。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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