我是ember的新手,似乎无法弄清楚为什么我的列表不会显示。这是我在路由页面上创建模型的代码:
import Ember from 'ember';
export default Ember.Route.extend({
model: function(){
return ['Ford', 'tesla','lexus'];
}
});
这是我的模板页面
<h1>Cars</h1>
<ul>
{{#each car in model}}
<li>{{car}}</li>
{{/each}}
</ul>
但由于某种原因,没有显示任何信息。有人注意到我没看到的东西吗?提前谢谢!
<p>
<strong>authors: </strong>
{{#each authors}}
{{this}},
{{/each}}
</p>
<h4>Comments</h4>
<ul>
{{#each comments as comment}}
<li><strong>{{name}}</strong> - {{comment}}</li>
{{/each}}
</ul>
和
export default Ember.Controller.extend({
action:{
sayHello: function(){
alert('Hello')
},
toggleBody: function(){
this.toggleProperty('isShowingBody');
},
submitAction: function(){
alert(this.get('name'));
alert(this.get('comment'));
}
},
title: 'My Bliog Post',
body: 'My body of work is endless i tell you',
authors: ['william','robert','michelle'],
created: new Date(),
comments: [
{
name: 'Evan',
comment: 'Hey what is new '
},{
name: 'Evan',
comment: 'Hey ith you'
},{
name: 'Evan',
comment: 'Hey what is n'
}
]
});
答案 0 :(得分:1)
您的每个陈述都有错误:
{{#each model as |car|}}
{{car}}
{{/each}}
例如:https://ember-twiddle.com/ed1ea81eb660a3ea2088c535961f2e2f?openFiles=templates.application.hbs%2C