3

ember.js pre 4では、(とりわけ)次のルートに応答するルーティングを実現しようとしています。

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

私が管理できる最初のルート(リストまで):リストのバリエーション(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

何か案は?

4

1 に答える 1

2

これは私にとってはうまくいくようです:

    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-02-05T17:08:12.993 に答える