当我打开OAuth的弹出窗口并通过
返回时window.opener.closeCallbackFunction();
然后我的ChangeDetection在转发页面上不再有效。
function _window(): any {
return window;
}
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
})
export class ConsultantRegisterComponent {
constructor() {
}
openPopup() {
let _this = this;
let selfWindow = _window();
let popup = lib.PopupCenter('/RegisterWithFacebook', 'Sign In', 600, 400);
selfWindow.closeCallbackFunction = function () {
popup.close();
_this.forward.call(_this);
};
}
forward() {
this.router.navigate(['/register-oauth']);
}
}
这是一个错误,还是我做错了什么?
答案 0 :(得分:0)
好的,谷歌搜索了一个解决方案:只需要用NgZone来做:
function _window(): any {
return window;
}
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
})
export class ConsultantRegisterComponent {
constructor(private _zone:NgZone) {
}
openPopup() {
let _this = this;
let selfWindow = _window();
let popup = lib.PopupCenter('/RegisterWithFacebook', 'Sign In', 600, 400);
selfWindow.closeCallbackFunction = function () {
popup.close();
_this.forward.call(_this);
};
}
forward() {
this._zone.run(() => {
this.router.navigate(['/register-oauth']);
});
}
}