我实际上是按照精确的程序来制作 ToDOMVC来制作这个的,但我无法弄清楚为什么我会在下面出现错误:
断言失败:#each 循环的值必须是数组。
您通过(生成的问题控制器)ember.js:394 Uncaught TypeError: Object [object Object] has no method 'addArrayObserver'
下面是代码
索引.html
<script type="text/x-handlebars" data-template-name="questions"><!--ACW-not sure should be question or equizz-->
<ul id="question-list" >
{{#each}}
<li>
<h3>{{title}}</h3>
</li>
<li>
<p>{{desc}}</p>
</li>
{{/each}}
</ul>
</script><!--template END-->
应用程序.js
window.Equizz = Ember.Application.create();
Equizz.ApplicationAdapter = DS.FixtureAdapter.extend();
路由器.js
Equizz.Router.map(function () {
this.resource('questions', { path: '/' });
});
Equizz.EquizzRoute = Ember.Route.extend({
model: function () {
return this.store.find('question');
}
});
问题.js
Equizz.Question = DS.Model.extend({
qid: DS.attr('string'),
category: DS.attr('string'),
type:DS.attr('string'),
title: DS.attr('string'),
desc: DS.attr('string'),
diff_level: DS.attr('string'),
answer: DS.attr('boolean')
});
Equizz.Question.FIXTURES = [
{
qid: '1',
category: 'Track',
type:'True & False',
title: 'Get 100 in the quizz is the most disgraced act in simulator lab.',
desc: 'think clearly, you should know the answer without use your brain...',
diff_level: 'Hard',
answer: false
},
{
qid: '2',
category: 'Common',
type:'True & False',
title: 'You are allowed to eat in simulator lab.',
desc: 'Like what? Halal?',
diff_level: 'Medium',
answer: false
},
{
qid: '3',
category: 'BS',
type:'True & False',
title: 'fsafasf asf asjfkl; as fkasl; faf a;sf sf asfl; sjlfjs a; fsl fas;f dsaf aslfj asl;fj a;fj alfj slafj a?',
desc: 'Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?Like what? Halal?',
diff_level: 'Easy',
answer: true
}
];