简体   繁体   English

Ember js和车把 - 每个都不起作用

[英]Ember js & handlebars - each not working

I'm new to Ember.js and I'm trying to get my head around it. 我是Ember.js的新手,我正试图绕过它。

I have the following code ( http://jsfiddle.net/6wPmW/ for a working example): 我有以下代码( 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: 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"));​

Surely I should get two <divs> created from the each loop? 当然我应该从每个循环中创建两个<divs>

The error is in your template: 错误发生在您的模板中:

{{#each MapSearch.ViewAddressesC}}

should be 应该

{{#each MapSearch.ViewAddressListC}}

See this JSFiddle . 看到这个JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM