2014-02-18 24 views
2

所以我在我的Handlebars标记中有两个不同的出口。一个插座未命名为{{outlet}},另一个插座名为{{outlet modal}}(我在Ember Cookbook中实现了一个模式)。决定在路线基础上呈现什么样的插座

我正在制作的应用程序的一个要求是,显示在模式中的内容应该是可链接的。例如,资源“汽车”应该出现在那里。我可以弄清楚如何建立一个到/cars/52的链接,并让它在那个出口处渲染,但是我该如何制作这样的路由规则?

你怎么能说路线(如/cars/:car_id)在特定的出路?

回答

3

请注意,当您开始渲染到不同的插座时,您需要确保插座也被渲染(也就是说,它是当前路线的父代,例如应用程序)。

App.CarsRoute = App.Route.extend({ 
    renderTemplate: function() { 
    this.render('cars', { // the template to render 
     into: 'application',   // the route to render into 
     outlet: 'modal',    // the name of the outlet in the route's template 
     controller: 'cars'  // the controller to use for the template 
    }); 
    } 
}); 

http://emberjs.com/guides/routing/rendering-a-template/

+0

谢谢!我会很快回报 –