私は EmberJS の初心者です。詳しく説明していただけると助かります。次のURLへのGETリクエストを期待する製品を取得するためのAPIエンドポイントがあります-
/api/products?date=2014-09-16&meal_type=2
ここで、日付と食事の種類はクエリ パラメータです。私のrouter.jsは次のようになります-
App.Router.map(function() {
this.resource('products', { path: '/products/date/:date/meal/:mealType'} );
});
App.Router.reopen({
location: 'history'
});
この動的ルートの理由は、アプリケーションの URL が同じ形式のように見えるためです。
routes/product.js は次のようになります-
App.ProductsRoute = Ember.Route.extend({
model: function(params) {
return this.store.findQuery('product', {date: params.date, meal_type: params.mealType});
},
queryParams: {
date: {
refreshModel: true
},
mealType: {
refreshModel: true
}
},
});
コントローラー/products_controller.js
App.ProductsController = Ember.ArrayController.extend({
queryParams: ['date', 'meal_type'],
date: null,
meal_type: null,
products: function() {
return this.get('model.content');
}.property()
ブラウザのコンソールにエラーが表示されます -
Error while loading route: undefined
これは ember.js?body=1:3522 行にあるようです。
どんな助けでも大歓迎です。ありがとう