मैं निम्नलिखित संस्करणों का उपयोग कर, ember.js और एंबर-डेटा का उपयोग करके ऐप्लिकेशन बनाने के लिए कोशिश कर रहा हूँ:के दौरान त्रुटि
DEBUG: Ember : 1.7.0
DEBUG: Ember Data : 1.0.0-beta.9
DEBUG: Handlebars : 1.2.1
DEBUG: jQuery : 2.1.0
मैं उपयोग कर रहा हूँ एक api से कनेक्ट करने के लिए RESTAdapter मैंने node.js. का उपयोग करके लिखा
जैसे ही मैं एप्लिकेशन मैं निम्नलिखित त्रुटि प्राप्त हो रही लोड के रूप में:
एप्लिकेशन:
Error while processing route: students undefined is not a function TypeError: undefined is not a function
at http://localhost:9000/scripts/vendor/ember-data.js:12006:34
at tryCatch (http://localhost:9000/scripts/vendor/ember.js:45818:16)
at invokeCallback (http://localhost:9000/scripts/vendor/ember.js:45830:17)
at publish (http://localhost:9000/scripts/vendor/ember.js:45801:11)
at http://localhost:9000/scripts/vendor/ember.js:29069:9
at DeferredActionQueues.invoke (http://localhost:9000/scripts/vendor/ember.js:634:18)
at Object.DeferredActionQueues.flush (http://localhost:9000/scripts/vendor/ember.js:684:15)
at Object.Backburner.end (http://localhost:9000/scripts/vendor/ember.js:147:27)
at Object.Backburner.run (http://localhost:9000/scripts/vendor/ember.js:202:20)
at apply (http://localhost:9000/scripts/vendor/ember.js:18382:27)
यहाँ कोड मैं उपयोग कर रहा हूँ (उसी क्रम मैं इसे चिपकाया में लोड) है। js
var App = window.App = Ember.Application.create({
LOG_ACTIVE_GENERATION: true,
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: false,
LOG_VIEW_LOOKUPS: true
});
store.js
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://localhost:3000',
serializer: DS.RESTSerializer.extend({
primaryKey: function(type) {
return '_id';
},
serializeId: function(id) {
return id.toString();
}
})
});
मॉडल/student.js
App.Student = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
nationality: DS.attr('string'),
createdAt: DS.attr('date')
});
मार्गों/app_route.js
App.StudentsRoute = Ember.Route.extend({
model: function() {
return this.store.find('student');
}
});
router.js
App.Router.map(function() {
this.resource('students', {path: '/'});
});
,210
और निम्न API की प्रतिक्रिया है:
{
students: [
{
nationality: "Lorem",
lastName: "Doe",
firstName: "John",
_id: "53f87200f3750319b4791235",
createdAt: "2014-08-23T10:50:40.661Z"
},
{
nationality: "Lorem",
lastName: "Doe",
firstName: "John",
_id: "53f87299f3750319b4791234",
createdAt: "2014-08-23T10:50:40.661Z"
}
]
}
ऐसा लगता है कि दुकान की तरह एपीआई से डेटा लोड हो रहा नहीं है, लेकिन JSON डेटा प्रारूप ठीक लग रहा है। क्या गलत हो सकता है के बारे में कोई विचार?
धन्यवाद!
मैं जब मैं 1.7.0 लेकिन 1.8.0 का उपयोग नहीं किया गया था लगता है कि मैं ठीक उसी त्रुटि है, जो शुरू कर दिया था -बेटा .1 ... 1.7.0 पर वापस स्विचिंग मेरे लिए तय है। सुनिश्चित नहीं है कि आपको समस्या क्यों हो रही है :( – Leeft
मेरा मानना है कि आपको किसी फ़ंक्शन के बजाय 'प्राथमिक कुंजी' में एक स्ट्रिंग का उपयोग करने की आवश्यकता है [दस्तावेज़ों के आधार पर] (http://emberjs.com/api/data/classes/DS .RESTSerializer.html # property_primaryKey)। कुछ 'प्राथमिकKey:' ' –