Ember路由:向导步骤的不同URL

时间:2014-06-21 14:20:30

标签: ember.js

Usecase:向导,包含许多步骤。最初使用{{partial currentStepTemplate}}实现。

我想重构一下,为每一步都有一个单独的控制器。最初执行了{{render currentStepTemplate controller=currentStepController}},但与{{partial}}不同,渲染不会绑定到currentStepTemplatecurrentStepController属性,而是将它们用作原始字符串。

我创建了一条路线/walkthrough/:step

问题在于路线上没有特定的模型,但我需要知道使用:step参数呈现的模板,该参数只能在{{{{}}中访问1}}挂钩。

model参数进一步传递给stepsetupController的方式使用模型看起来不是一个好的模式,但不确定如何否则我可以做到这一点。

renderTemplate

任何提示/想法?谢谢!

1 个答案:

答案 0 :(得分:1)

我很确定您正在尝试重新创建路由器的工作方式。我将每一步都移到资源下的路线上。然后您的网址将如下所示:

#/walkthrough/step1
#/walkthrough/step2
#/walkthrough/step3
#/walkthrough/step4

使用像

这样的路由器
App.Router.map(function() {
  this.resource('walkthrough', function(){
    this.route('step1');
    this.route('step2');
    this.route('step3');
    this.route('step4');
  });
});

http://emberjs.jsbin.com/musugiru/1/edit

相关问题