Seb*_*ndt 6 safari angular2-routing angular
在实际的Angular2 beta 14(及以前版本)中,似乎在Safari上使用后退按钮(当使用路由和几个视图时)(实际使用9.1)时出现问题:https://github.com/angular/angular/issues/7722
我也遇到过这个问题,而这在Chrome上运行良好.
我正在寻找解决方法,直到问题得到解决?
在"angular2":"2.0.0-beta.14"
我必须在一个区域内运行勾选才能让它为我工作.
import {ApplicationRef, <anything else you need>} from 'angular2/core';
import {Router,<anything else you need>} from 'angular2/router';
export class AppComponent {
constructor(private _ref: ApplicationRef, private _router: Router) {
_router.subscribe((value) => {
_ref.zone.run(() => _ref.tick());
});
}
}
Run Code Online (Sandbox Code Playgroud)
此错误有部分解决方法:
Router和注入ApplicationRef到应用程序组件中 router.subscribe((value)=>
{
//todo: check browser UA or any other parameters to detect back button, i.e. if (safari) {}
//trigger change that will invoke init methods
appRef.tick();
});
Run Code Online (Sandbox Code Playgroud)