我想将自定义html从特定页面传递到模板组件,以便使用Material(MdDialog)创建对话框.直到现在我可以将简单数据传递给模板,如下所示:
import { Component, OnInit, Input, TemplateRef } from '@angular/core';
import { MdDialog, MdDialogConfig, MdDialogRef } from '@angular/material';
import { DialogComponent } from './dialog.component';
@Component({
selector: 'app-commoncontent',
template: '
<div class="row pull-right">
<button md-raised-button (click)="open()" >{{"addButton" | translate}}
</button>
</div>',
styleUrls: ['./commoncontent.component.css']
})
export class CommoncontentComponent implements OnInit {
constructor(public dialog : MdDialog) { }
ngOnInit() {
}
open() {
let config = new MdDialogConfig()
let dialogRef:MdDialogRef<DialogComponent> =
this.dialog.open(DialogComponent, config);
dialogRef.componentInstance.content = "Hello Angular"
}
}
import { Component, OnInit, …Run Code Online (Sandbox Code Playgroud)