我的路由器看起来像:
App.Router.map(function () {
this.route('index', {path: '/'})
this.resource('products', function () {
this.route('all', {path: '/'});
this.resource('products.edit', {path: '/edit/:id'}, function () {
this.route('general');
this.route('images');
this.route('reviews');
});
});
this.resource('category', function () {
this.route('all', {path: '/'});
this.resource('category.edit', {path: '/edit/:category_id'}, function () {
this.route('general');
this.route('images');
this.route('products_of_category');
});
});
});
在导航菜单中,我添加/修改了Product
和添加/修改Category
,它们与products.edit
和category.edit
路由相关联。但是当我渲染页面时,我得到一个错误说:
TypeError: newHandlerInfo is undefined
当我删除子句:product_id
和:category_id
时,它可以正常工作。
以下是我的模特:
App.Product = Ember.Object.extend({
id: null,
productName: null,
dateAdded: null,
description: null,
price: null,
status: null,
categories: [],
categoryNames: []
});
App.Category = Ember.Object.extend({
id: null,
categoryName: null,
dateAdded: null,
description: null,
children: [],
parent: null,
products: []
});
答案 0 :(得分:0)
可能是这样的路由器:
App.Router.map(function() {
this.route('index', {path: '/'});
this.resource('products', function() {
this.route('all', {path: '/'});
this.route('edit_general', {path: '/edit/:product_id/general'});
this.route('edit_images', {path: '/edit/:product_id/images'});
this.route('edit_reviews', {path: '/edit/:product_id/reviews'});
});
this.resource('category', function() {
this.route('all', {path: '/'});
this.route('edit_general', {path: '/edit/:category_id/general'});
this.route('edit_images', {path: '/edit/:category_id/images'});
this.route('edit_products', {path: '/edit/:category_id/products'});
});
});