javascript - 带有 Angular 2 : Diasplay my angular 2 component inside dialog using displayDialogAsync 的 DialogAPI

标签 javascript angular angular2-routing office-js

我是 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/

相关文章:

javascript - 如何向用户发送大文件? Node Telegram Bot API

javascript - 灵活而强大的表单验证解决方案

javascript - 使用 Map 的 Angular 6 HttpClient

Angular2 - 加载映射模块时出现 SystemJS 404

Angular 4 Custom decorator - 注入(inject)服务

angularjs - Angular 2 - JWT 认证

Angular 2 : Trigger current route guards - handle logout action

javascript - 正确加载顺序 jQuery、Bootstrap 和 select2 .js 文件

javascript - 从 angularjs 中的 OAuth2 授权端点检索 token

通过浏览器 URL 导航时 Angular 2 路由不起作用