Angular2:打开弹出窗口并将组件加载到其中

时间:2016-04-15 18:21:19

标签: angular ecmascript-6

我有一个angular2应用程序,我想打开另一个窗口并加载一个组件。我目前正在使用本机JS window.open()方法,并将命令行路由的结果传递给它:

import { Component } from 'angular2/core';
import { Router } from 'angular2/router';

@Component({
  selector: 'uploader',
  template: `
    <div>
      <button type="button" (click)="startUpload()">
        Upload File
      </button>
    </div>
    `,
  styleUrls: []
})

export class UploaderComponent {
  constructor(private _router: Router) {}

  startUpload(mediaFile: File) {
    let windowObjectReference;

    windowObjectReference = window.open(
      // first param is location
      <string>this._router.navigate(['Feature']),
      'DescriptiveWindowName',
      'width=420,height=230,resizable,scrollbars=yes,status=0,toolbar=0,menubar=0,location=0'
    );

  }
}

结果是新窗口正确打开,但没有路由到目标组件。原始窗口(不是新弹出的窗口)路由到Feature路由。新窗口中的错误:

Cannot GET /src/[object%20Object]

知道我做错了什么吗?谢谢!

0 个答案:

没有答案