简体   繁体   English

如何使用 ng2 以编程方式 go 进行下一步

[英]How to go to next step programatically using ng2

I'm using Ng2-archwizard, what i want is to go to the next step using component.ts i mean with javascript function:我正在使用 Ng2-archwizard,我想要的是 go 到下一步使用 component.ts 我的意思是 javascript function:

<wizard>
  <wizard-step stepTitle="Title of step 1">
  Content of Step 1
  <button type="button" nextStep>Next Step</button>
  <button type="button" goToStep="2">Go directly to third Step</button>
</wizard-step>
<wizard-step stepTitle="Title of step 2" optionalStep>
  Content of Step 2
  <button type="button" previousStep>Go to previous step</button>
  <button type="button" nextStep>Go to next step</button>
</wizard-step>
<wizard-step stepTitle="Title of step 3">
  Content of Step 3
   <button type="button" previousStep>Previous Step</button>
  <button type="button" (click)="finishFunction()">Finish</button>
 >/wizard-step>

Try this in your component : 在您的组件中尝试:

  // At the top of my component class that implements the <wizard>
  @ViewChild(WizardComponent)
  public wizard: WizardComponent;

  // then later, this works great
  this.wizard.model.navigationMode.goToStep(1)

This really helped me, especially mentioning this is from ng2-archwizard.这真的帮助了我,特别是提到这是来自 ng2-archwizard。 Someone at my company basically copied the whole library and removed all reference of the creator(I added it back in) and so I couldn't figure out how this wizard component worked.我公司的某个人基本上复制了整个库并删除了创建者的所有引用(我重新添加了它),所以我无法弄清楚这个向导组件是如何工作的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM