在Ember.js中切换应用程序模板的推荐方法是什么?

时间:2014-01-06 03:06:46

标签: javascript ember.js

我一直在玩Ember.js,而我无法轻易找到的是如何切换基本应用程序模板。例如,假设我的应用程序有2个核心布局,一个在用户在注册之前了解应用程序时更具表现力,另一个是登录布局,即Web应用程序本身。

在条件基础上更改将使用哪种布局模板的推荐方法是什么?

更新

从解决方案中,我正在做的是:https://gist.github.com/eliperelman/8310055

2 个答案:

答案 0 :(得分:1)

你可以这样做:

App.ApplicationRoute = Ember.Route.extend({
  renderTemplate: function() {
    if(... authenticated ...) {
      this.render('authenticated');
    else{
      this.render('guest');
    }
  }
});

这将更改整个应用程序模板,但为两个模板保留相同的应用程序控制器(您可以使用控制器将哈希传递给render方法)。

答案 1 :(得分:1)

我在layoutNameBinding中使用ApplicationView。这个答案应该让你开始:https://stackoverflow.com/a/13980055/1234490(开始阅读'编辑')。

相关问题