ember.js - Unable to load data with emberJS -


i have following ember app. when go /products route i've got following error: error while loading route: typeerror {}

var app = ember.application.create(); app.router.map(function() {   this.route('products'); });  ds.store.extend({   revision: 11,   adapter: ds.restadapter.create() });  var product = ds.model.extend({});  var productsroute = ember.route.extend({   model: function() {     return app.product.find();   } }); 

first, code wont run because model , route not exist scope of app. should this:

var app = ember.application.create(); app.router.map(function() {     this.route('products'); });  ds.store.extend({     revision: 11,     adapter: ds.restadapter.create() });  app.product = ds.model.extend({});  app.productsroute = ember.route.extend({     model: function() {         return app.product.find();     } }); 

next, may want replace:

this.route('products'); 

with:

this.resource('products'); 

as using restadapter.

finally ds.model should specify fields should user json response:

app.product = ds.model.extend({     name: ds.attr('string') }); 

hope help.


Comments

Popular posts from this blog

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -