【问题标题】:Ember.js pre4 multiple nested routingEmber.js pre4 多重嵌套路由
【发布时间】:2013-02-05 16:49:45
【问题描述】:

在 ember.js pre 4 中,我试图实现一个响应以下路由(以及其他路由)的路由:

/contact/[id]
/contact/edit
/contact/new
/contact/list
/contact/list/my
/contact/list/team
/contact/list/groups

我可以管理的第一条路线(最多列出): list (my/team/groups) 的变体是我苦苦挣扎的地方。我只是得到一个:“没有路由在调用它时出现 URL '/contact/list/my' 错误。

关于如何实现这种嵌套,我尝试了多种变体。这是我目前的尝试:

    App.Router.map(function()
    {
        this.route("index");

        this.resource("contact", function(){
            this.route('new');
            this.route('show', { path: "/:contact_id" });
            this.route('edit', { path: "edit/:contact_id" });
        });

        this.resource("contact.list", function(){
            this.route("index");
            this.route("my");
        });


    });

查看 App.Router.router.recognizer.names:我看到以下输出:

contact.edit: Object
contact.index: Object
contact.list.index: Object
contact.list.my: Object
contact.new: Object
contact.show: Object
index: Object
__proto__: Object

有什么想法吗?

【问题讨论】:

    标签: ember.js


    【解决方案1】:

    这似乎对我有用:

        App.Router.map(function()
        {
            this.route("index");
    
            this.resource("contact", function(){
                this.route('new');
                this.route('show', { path: "/:contact_id" });
                this.route('edit', { path: "edit/:contact_id" });
                this.resource("contact.list", { path: "list/" },function(){
                    this.route("index");
                    this.route("my");
                });
            });
        });
    

    【讨论】:

      猜你喜欢
      • 2013-01-09
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 2013-07-20
      • 2012-11-18
      • 2015-03-18
      • 1970-01-01
      • 2013-11-04
      相关资源
      最近更新 更多