2012-10-24 55 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