Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
Javascript 角形多步法布线_Javascript_Angular - Fatal编程技术网

Javascript 角形多步法布线

Javascript 角形多步法布线,javascript,angular,Javascript,Angular,我是angular的新手,我正在使用angular 4构建一个多步骤表单。目前,组件结构如下所示: -apply.component --step-one.component --step-two.component --step-three.component 路由器的设置如下: { path: '', redirectTo: '/apply', pathMatch: 'full' }, { path: 'apply', component: ApplyComponent, ch

我是angular的新手,我正在使用angular 4构建一个多步骤表单。目前,组件结构如下所示:

-apply.component
--step-one.component
--step-two.component
--step-three.component
路由器的设置如下:

{
 path: '',
 redirectTo: '/apply',
 pathMatch: 'full'
},
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent,
     outlet: 'step1'
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
      outlet: 'step2'
   }
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
   }
}
<router-outlet>Steps will be loaded here</router-outlet>
ApplyComponent中的路由器出口:

 <router-outlet name="step1">Child 1 in apply comp</router-outlet>
 <router-outlet name="step2">Child 2 in apply comp</router-outlet>
应用组件中的子级1 申请公司中的儿童2 当使用完成一个部分时,它应该隐藏,如下一部分所示。每个部分都是父组件上的路由器出口

我正试图找出最好的方法来编排每个部分的显示/隐藏。我已经知道如何激活前一条路线中的每条路线,但是我应该如何隐藏或销毁前一条路线(部分)?是否每个部分都应该在一个文档中生成?如何协调所有不同部分的交互(返回/编辑/下一步)


编辑:另一个想法,是否所有组件都应该在父级中定义,然后在移动到下一步时显示/隐藏,然后更新路由?在我当前的路由器更新组件实现中,我可能会逆向考虑这一点,而不是组件更新路由。

我建议使用单个路由器出口来显示步骤。从路由配置中删除已命名的路由器出口,并从路由器出口标记中删除该名称。我假设您已经有了“下一步”和“上一步”按钮来在步骤之间移动。现在,您不必担心显示/隐藏逻辑,路由器会为您解决这一问题。您可能需要添加以防止用户篡改url

您的路由器配置如下所示:

{
 path: '',
 redirectTo: '/apply',
 pathMatch: 'full'
},
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent,
     outlet: 'step1'
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
      outlet: 'step2'
   }
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
   }
}
<router-outlet>Steps will be loaded here</router-outlet>
您的单个路由器插座如下所示:

{
 path: '',
 redirectTo: '/apply',
 pathMatch: 'full'
},
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent,
     outlet: 'step1'
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
      outlet: 'step2'
   }
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
   }
}
<router-outlet>Steps will be loaded here</router-outlet>
步骤将在此处加载

我建议使用一个路由器插座来显示步骤。从路由配置中删除已命名的路由器出口,并从路由器出口标记中删除该名称。我假设您已经有了“下一步”和“上一步”按钮来在步骤之间移动。现在,您不必担心显示/隐藏逻辑,路由器会为您解决这一问题。您可能需要添加以防止用户篡改url

您的路由器配置如下所示:

{
 path: '',
 redirectTo: '/apply',
 pathMatch: 'full'
},
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent,
     outlet: 'step1'
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
      outlet: 'step2'
   }
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
   }
}
<router-outlet>Steps will be loaded here</router-outlet>
您的单个路由器插座如下所示:

{
 path: '',
 redirectTo: '/apply',
 pathMatch: 'full'
},
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent,
     outlet: 'step1'
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
      outlet: 'step2'
   }
{
 path: 'apply',
 component: ApplyComponent,
 children: [
   {
     path: 'personalInfo',
     component: StepOneComponent
   },
   {
      path: 'employmentInfo',
      component: StepTwoComponent,
   }
}
<router-outlet>Steps will be loaded here</router-outlet>
步骤将在此处加载

是的,我很早就开始玩这个游戏了,这可能是我要走的方向。谢谢是的,我很早就开始玩这个了,这可能是我要走的方向。谢谢