在Ember.JS中为单个路由禁用application.hbs

在Ember.JS中为单个路由禁用application.hbs,ember.js,Ember.js,简单地说,web应用程序99%的时间都需要使用application.hbs模板,但对于单个路由,我想禁用它并仅呈现路由模板 比如“Layout=null;”在asp.net中 提前感谢。最简单的答案是,您需要将所有共享布局的路由嵌套在一个公共父路由下,因为您无法删除应用程序模板。这可以通过两种不同的方式完成,具体取决于目标 如果它们都共享一个URL段,则可以将其放在公共父项下: Router.map(function() { this.route('pretty-layout', func

简单地说,web应用程序99%的时间都需要使用application.hbs模板,但对于单个路由,我想禁用它并仅呈现路由模板

比如“Layout=null;”在asp.net中


提前感谢。

最简单的答案是,您需要将所有共享布局的路由嵌套在一个公共父路由下,因为您无法删除应用程序模板。这可以通过两种不同的方式完成,具体取决于目标

如果它们都共享一个URL段,则可以将其放在公共父项下:

Router.map(function() {
  this.route('pretty-layout', function() {
    this.route('page-1'); // http://localhost:4200/pretty-layout/page-1
    this.route('page-2'); // http://localhost:4200/pretty-layout/page-2
  });
});
您可以覆盖顶级索引路由。您可能需要将当前的
应用程序.index
移动到
应用程序.index.index

 Router.map(function() {
  this.route('index', { path: '/' }, function() {
    this.route('page-1'); // http://localhost:4200/page-1
    this.route('page-2'); // http://localhost:4200/page-2
  });
});