[英]Ember.js Routes: Dynamic segments in url error
My Router looks like: 我的路由器看起来像:
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');
});
});
});
In navigation menu I have Add/Edit Product
and Add/Edit Category
and they linked to products.edit
and category.edit
routes. 在导航菜单中,我具有“添加/编辑
Product
和“添加/编辑Category
,它们链接到products.edit
和category.edit
路线。 But when I render page I get an error saying: 但是,当我渲染页面时,我收到一条错误消息:
TypeError: newHandlerInfo is undefined
When I remove slugs :product_id
and :category_id
it works fine. 当我删除块
:product_id
和:category_id
它工作正常。
Here are my models: 这是我的模型:
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: []
});
May be a router like this is what you want: 可能是这样的路由器,是您想要的:
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'});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.