Ember.js - How to properly bind a collection to a view using Ember.Router?

…衆ロ難τιáo~ 提交于 2019-11-30 10:11:31
Jason P

The binding doesn't work because "the array is mutating, but the property itself is not changing". https://stackoverflow.com/a/10355003/603636

Using App.initialize and Ember.Router, views and controllers are now being automagically connected. There is very little reason to manually bind contacts in your view to the controller's content as you already have access to it.

Change your view's template to include:

{{#if controller.isLoaded}} // set this true in your ajax success function
  {{#each contact in controller}}
    {{view App.ContactListItemView contactBinding="contact"}}
  {/each}}
{{else}}
  <tr>
    <td colspan="2">
       You have no contacts <br />
       :( 
    <td>
  </tr>
{{/if}}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!