Ember.js如何同时显示两条路线 [英] Ember.js How to show two routes at the same time

查看:112
本文介绍了Ember.js如何同时显示两条路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上显示一个产品,就像这样: /#/ products / 1 。用户可以同时打开一个页面,此页面将显示在产品的顶部。就像一个覆盖,像​​产品页面一点点。所以你可以看到它后面的一些产品。

I show a product on the website, just like this: /#/products/1. The user can open a page at the same time, this page will be on top of the show product. Just like an overlay, a little smaller as the product page. So that you can see a little bit of the product behind it.

我认为这个URL应该是: /#/ products / 1 / page / 1 。因此,用户可以将打开的页面的链接与产品共享。

I think the url should be: /#/products/1/page/1. So the user can share the link of the opened page with the product.

结果是此路由器:

Router.map(function() {

    this.resource(products, function() {   

         this.resource(product, function(path: ':product_id') {  

              this.resource('page', function(path: ':page_id'));

         });
    }); 
});

这是Ember练习吗?或者应该以另一种方式完成?

Is this good Ember practice? Or should it be done another way?

感谢您分享任何想法。

推荐答案

完全正确,你做错了,但是嵌套的资源是要走的路

Totally fine, your doing it a bit wrong, but nested resources is the way to go

Router.map(function() {
    this.resource('products', function() {   
         this.resource('product', {path: ':product_id'}, function() {  
              this.resource('page', {path: 'page/:page_id'}, function());
         });
    }); 
});

这篇关于Ember.js如何同时显示两条路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆