【发布时间】:2017-10-26 22:58:54
【问题描述】:
我想在执行承诺时刷新页面(通过 this.navigate.url),但我似乎无法使其工作。
import {Router} from '@angular/router';
constructor(public router: Router) {
}
myPromise('/api/users').then((response) => {
return response.json();
}).then(function (response) {
this.router.navigate.url([url]);
});
我什至尝试过 window.location.reload,但它也不起作用。
【问题讨论】:
-
这里的
this是什么?this.navigate是做什么的?url来自哪里?控制台显示什么? -
您想在 Angular 路由器 och 的帮助下在您的应用程序内部导航到外部站点吗?如果是外部的,请尝试
window.location.replace("http://something.com"); -
@torazaburo 我编辑了我的问题以进一步阐述。 router 是Router 类的一个实例,url 是当前页面的URL。我想要的是在执行承诺后刷新当前页面。
-
@FredrikLundin 我想在成功执行承诺后刷新我的页面。
-
@torazaburo 是否有参考来纠正打字稿/角度的这个答案?喜欢:stackoverflow.com/questions/20279484/…