[英]Ember-CLI Route model data not affecting template
I have an ember route webtest
contained within the file routes/webtest.js
: 我在文件routes/webtest.js
包含了余烬路线webtest
:
export default Ember.Route.extend({
model: function() {
return {
title: "Does not appear"
};
}
});
I have the matching template contained within templates/webtest.hbs
我的templates/webtest.hbs
包含匹配的模板
<div class="container">
<h2>Title: {{title}}</h2>
</div>
when I navigate to the page /webtest in my web browser with ember serve
the resulting page has the title:
text, but not the text does not appear
当我浏览网页/ WebTest的在我的网页浏览器ember serve
所产生的页面具有title:
文本,而不是文本does not appear
I have been to multiple ember pages, and I have the same code working here: http://jsbin.com/neheru/6/edit?html,js,output 我去过多个余烬页面,并且在这里使用相同的代码: http ://jsbin.com/neheru/6/edit?html,js, output
The goal is to be able to have a variable accessible from within the template webtest
that can be accessed by a route. 目标是能够从模板webtest
中访问可通过路由访问的变量。
FYI I'm trying to get it to the template so I can pass variables to a component 仅供参考,我正在尝试将其传递到模板,以便可以将变量传递给组件
The variable should be {{model.title}} 该变量应为{{model.title}}
You can log out variables from your template with 您可以使用以下命令从模板中注销变量
{{log title}}
{{log controller.title}}
{{log model.title}}
This might help you to debug faster. 这可以帮助您更快地调试。
You should then be able to pass data in to our component with something like: 然后,您应该可以通过以下方式将数据传递到我们的组件中:
{{my-component title=model.title}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.