【发布时间】:2018-09-21 14:53:47
【问题描述】:
自 Angular 2 以来,ng-gapi 出现问题。我需要显示谷歌“托管配置 iframe”,我按照Google developper doc 中的步骤操作,它适用于 angularJS,但是当我使用 Angular 2+ 进行尝试时它没有。
this.gapiService.onLoad().subscribe((result:any)=> {
gapi.load("gapi.iframes", function(){
var iframeContainer = document.getElementById('iframecontainer');
var context = gapi.iframes.getContext();
var options = {
'url': this.url,
'where': iframeContainer,
'attributes': {
style: 'height:1200px',
scrolling: 'yes'
}
}
var iframe = context.openChild(options);
iframe.register('onconfigupdated', function(o) {
console.log(o);
this.data.mcmId = o.mcmId;
this.dialogRef.close(this.data);
} , function(data) {
return true;
});
iframe.register('onconfigdeleted', function(o) {
console.log(o);
this.data.mcmId = null;
this.dialogRef.close(this.data);
} , function(data) {
return true;
});
});
});
问题是我认为 GAPI 中不存在 iframe,我需要使用 Gapi 渲染 iframe 以捕获“onconfigupdated”和“onconfigdeleted”事件。
【问题讨论】:
标签: javascript angular iframe google-api-js-client