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

前端 未结 1 2026
北海茫月
北海茫月 2021-01-01 05:20

I was previously working with Ember.StateManager and now I\'m doing some tests before I finally switch to Ember.Router, but I\'m failing to underst

相关标签:
1条回答
  • 2021-01-01 06:07

    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}}
    
    0 讨论(0)
提交回复
热议问题