我正在尝试创建通用对话框组件(基于@ angular / material),它将由路由器安装。
示例,MaterialDialog如何在没有泛型的情况下工作
Version1: echo '<button class="btn" onclick="myFunction('pd')">PD</button>';
Version2: echo '<button class="btn" onclick="myFunction("pd")">PD</button>';
如果我机械地应用TS泛型,我会在ngOnInit中得到编译错误。
import { Component, OnInit } from '@angular/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { ConcreteComponent } from '../concrete/concrete.component';
@Component({
selector: 'wrapping-component',
template: '<div></div>',
styleUrls: [],
})
export class WrappingComponent implements OnInit {
private ref: MdDialogRef<ConcreteComponent>;
constructor(private dialog: MdDialog) {}
ngOnInit() {
this.ref = this.dialog.open(ConcreateComponent, {});
}
}
想法?如何使这项工作?