Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ember.js路由名称_Ember.js - Fatal编程技术网

使用ember.js路由名称

使用ember.js路由名称,ember.js,Ember.js,我有一个这样的路由器 App.Router.map(function () { this.route("about"); this.resource("invoices", { path: "/invoices" }, function () { this.resource("invoices.show", { path: "/:id" }); this.resource("invoices.update", { path: "/:id/edit"

我有一个这样的路由器

App.Router.map(function () {
    this.route("about");
    this.resource("invoices", { path: "/invoices" }, function () {
        this.resource("invoices.show", { path: "/:id" });
        this.resource("invoices.update", { path: "/:id/edit" });
        this.route("create");
    });
});
为了生成到各种路线和资源的链接,我有这个

<nav>
    {{#linkTo "invoices.index"}}Invoices{{/linkTo}}
    {{#linkTo "invoices.show" 1}}Invoice{{/linkTo}}
    {{#linkTo "invoices.create"}}New invoice{{/linkTo}}
</nav>

而且它会自动为资源名添加前缀,因为它们嵌套在invoices资源中。是吗?

是的,嵌套资源可以堆叠它们的名称,并且您应该能够使用点表示法引用嵌套路由

但是,您需要执行以下操作:

    this.resource("invoices", { path: "/invoices" }, function () {
        // invoices.show
        this.resource("show", { path: "/:id" }, function() { 
             // invoices.show.update
             this.route("update", { path: "/edit" });
        });
        // invoices.create
        this.route("create");
    });
因为更新操作依赖于提供给显示路由的对象


基本上,依赖于相同或父路由中使用的资源子集的嵌套元素应定义为资源映射。叶节点可以定义为基本路由。

是的,嵌套资源可以堆叠它们的名称,并且您应该能够使用点符号引用嵌套路由

但是,您需要执行以下操作:

    this.resource("invoices", { path: "/invoices" }, function () {
        // invoices.show
        this.resource("show", { path: "/:id" }, function() { 
             // invoices.show.update
             this.route("update", { path: "/edit" });
        });
        // invoices.create
        this.route("create");
    });
因为更新操作依赖于提供给显示路由的对象

基本上,依赖于相同或父路由中使用的资源子集的嵌套元素应定义为资源映射。叶节点可以定义为基本路由