我是Ember.js的新手,我正试图绕过它。
我有以下代码(http://jsfiddle.net/6wPmW/作为工作示例):
<script type="text/x-handlebars">
<div id="ViewAddresses" class="location_search_results selected_searches clearfix">
<div>
<div>
{{#each MapSearch.ViewAddressesC}}
<div class="row">ghfdg</div>
{{/each}}
</div>
</div>
</div>
</script>
JS:
MapSearch = Ember.Application.create();
MapSearch.ListAddress = Ember.Object.extend({
list_info: null,
node_level: null,
node_value: null,
removed_properties: null
});
MapSearch.ViewAddressListC = Ember.ArrayController.create({
content: [],
initialize: function() {
me = this;
var l = MapSearch.ListAddress.create({
node_level: "test",
node_value: "test"
});
me.pushObject(l);
var l = MapSearch.ListAddress.create({
node_level: "test",
node_value: "test"
});
me.pushObject(l);
console.log(me);
}
});
MapSearch.ViewAddressListC.initialize();
console.log(MapSearch.ViewAddressListC.get("content"));
当然,我应该从每个循环中创建两个<divs>
?
答案 0 :(得分:2)
错误在您的模板中:
{{#each MapSearch.ViewAddressesC}}
应该是
{{#each MapSearch.ViewAddressListC}}
请参阅this JSFiddle。