2012-10-24 56 views
0

我是Ember.js的新手,我试图让自己的头靠近它。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>从每个环路产生的?

回答

2

的错误是在您的模板:

{{#each MapSearch.ViewAddressesC}} 

应该

{{#each MapSearch.ViewAddressListC}} 

this JSFiddle

+1

上帝。该死的。它。 3小时.... 3小时我花了...所有的错字!非常感谢你。 – rickyduck

+0

太糟糕了......但不用担心,你会玩Ember.js的速度越快,最快你就会解决这类问题 –

+0

是的。此刻,我真的很开心。看起来很容易,但有时很容易,我觉得我做错了事情。实践使得完美,但它是一个很棒的框架。 – rickyduck