0

我是 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>从每个循环中创建两个?

4

1 回答 1

2

错误在您的模板中:

{{#each MapSearch.ViewAddressesC}}

应该

{{#each MapSearch.ViewAddressListC}}

请参阅此 JSFiddle

于 2012-10-24T15:16:24.847 回答