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从上一个路由获取对象_Ember.js - Fatal编程技术网

Ember.js Ember js从上一个路由获取对象

Ember.js Ember js从上一个路由获取对象,ember.js,Ember.js,我正在构建我的第一个EmberJS应用程序 从索引路由开始,我将显示一个A。当用户单击A时,它将路由到/A。组件A将有一个字段url,填写并单击按钮后,它将路由到/b。组件B也有一个字段电子邮件。填写并单击一个按钮,它将发送到/summary,其中显示我在a和B中填写的内容。我如何在最佳实践中做到这一点 我正在使用ember cli和这个。转换到(/b)去路由/b看起来嵌套路由对这个实现很好。 /a路线 model(){ return {url:'default'}; } a、 哈佛商学院

我正在构建我的第一个EmberJS应用程序

从索引路由开始,我将显示一个A。当用户单击A时,它将路由到
/A
。组件A将有一个字段
url
,填写并单击按钮后,它将路由到
/b
。组件B也有一个字段电子邮件。填写并单击一个按钮,它将发送到
/summary
,其中显示我在a和B中填写的内容。我如何在最佳实践中做到这一点


我正在使用
ember cli
这个。转换到(/b)
去路由
/b
看起来嵌套路由对这个实现很好。
/a路线

model(){
 return {url:'default'};
}
a、 哈佛商学院

/a/b-路线

model(){
 return {email:''};
}
a/b.hbs

{{comp-b model=model}}
/a/b/摘要-路线

model(){
 return {amodel:this.modelFor('a'),bmodel:this.modelFor('b')};
}
a/b/summary.hbs

{{comp-a model=model.amodel }}
{{comp-b model=model.bmodel }}

下面是一个教程,它精确地解释了如何按照您的要求制作一个多步骤表单

使用嵌套布线系统,这是相当直接的

Router.map(function() {
  this.route('checkout', function() {
    this.route('personal-info');
    this.route('shipping-info');
    this.route('payment-info');
    this.route('confirmation');
  });
});
然后,您可以使用“订单”或某种“表单”模型来保持信息的活跃性


我遵循了这个示例,并构建了一个具有编辑和最后确认功能的示例。:)

我不能像ReactJS那样创建共享存储并在任何地方导入吗?到目前为止,我还没有找到如何制作大豆的方法。这是另一个选择,你可以通过创建。这样你就可以在任何地方注入它来获取数据如果我使用{{{#link to}},服务就会消失?不会的。这里是
Ember的定义。服务
是一个在应用程序期间存在的Ember对象,可以在应用程序的不同部分中使用。您可以传递路由名称
this。传递到('a')
您应该为此构建一个Ember twidle。:)
Router.map(function() {
  this.route('checkout', function() {
    this.route('personal-info');
    this.route('shipping-info');
    this.route('payment-info');
    this.route('confirmation');
  });
});