我是 Angular 2 和 office js 的新手。我阅读了 displayDialogAsync 并创建了一个示例。
我的工作示例现在显示 html 页面,但我想在 office js 对话框中显示 angular 2 组件,然后尝试将其重定向到不同的域。
HTML 页面:Waiting.html(等待 2 秒)
app.Component.html:::
<div>
<router-outlet></router-outlet>
<br /> Testing...
<div class="ms-Grid">
<div class="ms-Grid-row">
<div class="ms-Grid-col">
<input type="button" value="OpenDialog" (click)="openDialog()" />
</div>
</div>
</div>
</div>
组件:AppComponent
import { Component, OnInit, Input } from '@angular/core';
import { WordService } from './office/word.service';
import { Router, ActivatedRoute, ActivatedRouteSnapshot, NavigationEnd, RouterStateSnapshot, Event, UrlSerializer } from '@angular/router';
import { Location } from '@angular/common'
@Component({
moduleId: module.id,
selector: 'addin',
templateUrl: 'app.component.html',
providers: [WordService]
})
export class AppComponent implements OnInit {
title: string = 'Angular 2 Excel Add-in';
private newURL: string;
constructor(private wordService: WordService, private _router: Router, private _activatedroute: ActivatedRoute,
private urlSerializer: UrlSerializer,
private location: Location) {}
ngOnInit() { }
openDialog() {
this.newURL = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + "/Waiting.html";
Office.context.ui.displayDialogAsync(this.newURL, { height: 50, width: 50 });
//Office.context.ui.displayDialogAsync(this._router.navigate(['login/test']), { height: 20, width: 20 });
}
}
预期结果 :
在对话框中显示任何组件,然后重定向到 customdomin 并从 customdomain 获取响应并将其传递给我们的 office 加载项。
请帮我。
提前致谢。
最佳答案
当您在等待更好的答案时,请查看本文的最后一部分 Dialog API in Office Add-ins这是关于在单页加载项中使用对话框。
关于javascript - 带有 Angular 2 : Diasplay my angular 2 component inside dialog using displayDialogAsync 的 DialogAPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42001882/