Ember-data DS.RESTAdapter raises TypeError

I am trying to use Ember.js with ember data and I have the following application:

window.App = Ember.Application.create()

App.store = DS.Store.create
    revision: 4
    adapter: DS.RESTAdapter.create { bulkCommit: false }

App.Source = DS.Model.extend
    # options
    primaryKey: '_id'

    # fields
    name: DS.attr 'string'
    raw_text: DS.attr 'string'

App.sourcesController = Ember.ArrayProxy.create
    content: App.store.findAll App.Source

App.ListSourcesView = Ember.View.extend
    templateName: 'app/templates/sources/list'
    sourcesBinding: 'App.sourcesController'

This template is as follows:

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
        </tr>
    </thead>
    <tbody>
        {{#each sources}}
        {{view App.ShowSourceView sourceBinding="this"}}
        {{/each}}
    </tbody>
</table>

When I try to download App.ListSourcesViewon my page, I get an error message in data.js-ember: Uncaught TypeError: Cannot read property 'map' of undefined.

I cannot understand what I am doing wrong, and reading through the source does not help my confusion in this case. Has anyone experienced this or can tell me that I have identified / not defined correctly?

+3
source share
3 answers

, , . , ember , , , /users/, { "users": [] }, [].

+2

ember/ember github master? . master , ( ).

0
App.sourcesController = Ember.ArrayProxy.create
     content: []

App.ListSourcesView = Ember.View.extend
     // I don't believe you can use file paths in this way
     // Use a script tag with a  data-template-name as shown in the docs.
     // If you really need them from a file, then you will need to compile the templates
     // Yourself. There plenty of SO Questions re: this.
     templateName: 'source-list'
     sourcesBinding: 'App.sourcesController'

// Always access ember object properties through the get and set interfaces.
// This will ensure that views get the proper notifications when props change.
App.sourcesController.set("content", App.store.findAll App.Source);

, !

0

All Articles