EmberJS:多次使用页面的正确方法

时间:2014-09-10 15:45:10

标签: ember.js architecture

我有一个产品索引页面需要多次使用:

# All products
product-index -> product

# Categorized products
category -> subcategory -> product-index -> product

# A persons products
profile -> product-index -> product

如您所见,product-indexproduct路由嵌套在多种情况下。在所有情况下,每个视图都是一个全屏页面,用户可以从所有页面导航回到根页面。

我的想法是像这样配置路由器:

// router.js
this.resource( "products", function() {
  this.route( "product", { path: "/:product_id" } ); 
} );

this.resource( "categories", function() {
  this.route( "category", { path: "/:category_id" }, function(){
    this.resource( "products", function() {
      this.route( "product", { path: "/:product_id" } ); 
    } );
  } );
} );

this.route( "profile", function() {
  this.resource( "products", function() {
    this.route( "product", { path: "/:product_id" } ); 
  } );
} );

但是我想知道上面是否是正确的方法,或者我可能总是链接到同一产品索引页面并过滤产品。 (例如products?cat=bagsproducts?user=12

此外,当我要使用第一个解决方案时,我需要能够重新使用我的products controller,但我还不确定。

现在我想知道做什么是正确的,贪婪的,为什么?

0 个答案:

没有答案
相关问题