首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将我的路由绑定到angular-material2 2中的stepper?

如何将我的路由绑定到angular-material2 2中的stepper?
EN

Stack Overflow用户
提问于 2017-12-15 00:33:35
回答 1查看 2.3K关注 0票数 4

我使用的是angular-material2 2的Stepper component,我希望这些步骤反映在我的应用程序的URL路由中,这样用户就可以共享这些URL链接并立即执行正确的步骤。有可能吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-13 02:13:09

您需要从'@angular/common'注入和使用位置服务

1)更改定位服务的URL调用go功能。示例:

代码语言:javascript
复制
if (this.stepper.selected.label === 'subscriber') { 
    this.location.go('./enrollment/subscriberInfo');
}

2)更换定位业务的URL变更呼叫用户功能后的步进器。示例:

代码语言:javascript
复制
this.location.subscribe( () => {
    if (this.location.isCurrentPathEqualTo('/enrollment/subscriberInfo')) {
        this.stepper.selectedIndex = 0;
    }
    if (this.location.isCurrentPathEqualTo('/enrollment/payment')) {
        this.stepper.selectedIndex = 1;
    } 
    if (this.location.isCurrentPathEqualTo('/enrollment/agreement')) {
        this.stepper.selectedIndex = 2;
    }
});`

仅供参考,我使用stepper的@Output() animationDone: EventEmitter<void>修改了网址。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47818129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档