angular - end void 方法后重定向
问题描述
刷新页面时遇到问题
我有一个运行以下代码的服务:
服务.ts
public goToCommit(value: boolean) {
if (this.accountServ.isAutho() || this.person.getNb() % 48 === 0) {
this.personService.savePerson(this.person).subscribe(() => {
this.person= null;
});
} else {
throw new Error('Account not authorized to goToCommit');
}
}
(这个处理比较长,其他地方也用这个方法)
在我的组件中,我有这个:
组件.ts
this.service.goToCommit(value);
this.router.navigate (['/persons']);
问题是我/persons
在处理结束之前被重定向到。
我如何等待goToCommit
方法完成并在之后重定向?
谢谢
解决方案
推荐阅读
- java - 从数据库加载 netflix zuul 路由值
- python - Gstreamer、Docker、udpsrc、OpenCV、Python... 不工作
- laravel - Laravel 日志异常
- vba - VBA - 如果单元格值更改,则移动行
- javascript - 使用 sequelize 获取字段中具有唯一值的所有行
- javascript - 检查并匹配文件扩展名
- flutter - Flutter:如何在不使用标签栏视图的情况下使用导航器创建标签栏?
- gitlab - 在 GitLab 中更改导航主题颜色
- sql - 每天插入数百万条记录的表需要操作或检查?
- java - Eclipse 中带有 SOAP Web 服务的 Drools