我正在我的angular 8应用程序中设置一个第三方登录页面。
我正在将第三方身份管理集成到angular 8应用程序中。 我正在使用iframe加载第三方登录页面并能够使用凭据登录,但是登录后我如何从iframe获得响应。因为登录后我需要显示父页面。谢谢。
我在google中尝试过,但没有找到任何解决方案...这是正确的方法还是其他方法?我正在为此使用角度8。
答案 0 :(得分:0)
window.parent.someMethodDefinedInOpenWindow(data);
//someMethodDefinedInOpenWindow is defined in electron app/ other iframe loaded //app
<iframe id="" class="" height="100%" width="100%" style="border: 0;" [src]="urlSafe"></iframe>
@Pipe({
name: 'domSanitizer'
})
export class DomSanitizerPipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer) { }
transform(htmlString: string, args?: any): any {
return this.sanitizer.bypassSecurityTrustHtml(htmlString);
}
}
constructor(
public sanitizer:DomSanitizer
) {
this.urlSafe = this.sanitizer.bypassSecurityTrustResourceUrl('https://.....');
}
window.parent.someMethodDefinedInOpenWindow(data);
//someMethodDefinedInOpenWindow is defined in electron app/ other iframe loaded //app
someMethodDefinedInOpenWindow (){
// I am inside iframe app
}
<app-root></app-root>
<script type="text/javascript">
//updateFromDevice is called from iframe
function updateFromDevice(data) {
window['componentRef'].zone.run(() => {
window['componentRef'].component.updateFromIframe(data);
});
}
</script>
constructor(
private zone: NgZone,
) {
window['componentRef'] = {
zone: this.zone,
componentFn: (value) => this.updateFromIframe(value),
component: this
};
}
updateFromIframe(data) {}