【发布时间】:2021-04-22 02:13:46
【问题描述】:
我使用 angular 10,并且有下一个代码
this.recognizer.voiceText.subscribe((text) => {
console.log(text)
if (text.includes('menu')) {
this.preProcess();
this.opened = true;
this.postProcess();
}
if (text.includes('bots')) {
this.preProcess();
this.router.navigate(['bots']);
this.postProcess();
}
}, error => {
}, () => {
});
所以我在“this.router.navigate”之后得到了奇怪的逻辑——Angular 只是在当前页面之后添加我的新页面。 请看1张现在的样子和以前的样子(2张)
【问题讨论】:
-
请提供您的模板
html和您的...routing.module.ts文件。或提供堆栈闪电战(例如) -
@DavidB。在我的 html 中,我只有 == 所以如果我打电话给路由器。按按钮导航 - 工作正常我不知道为什么订阅失败
-
这在我看来像是嵌套
的问题,并且没有正确定义路由模块中的子路由。 (如 app.component.html 中的一个路由器插座和 menu.component.html 中的另一个) -
@DavidB。我不这么认为。因为它工作得很好,如果我只是在没有 .subscribe() 的情况下调用 router.navigate
-
您还能提供更多代码吗?例如。一个有效的。
标签: angular typescript rxjs router angular10