【发布时间】:2020-09-12 03:01:12
【问题描述】:
我有component1,它导入component2并使用它的功能。 这个函数从component2调用对话窗口。
export class component1 implements OnInit {
@Output() testVar= new EventEmitter();
openDialog(){
this.testVar.emit(200);
const dialogRef = this.dialog.open(Component2, {
现在我想以某种方式将变量发送到该组件。因此,当第二个组件 OnInit 可以获取我的变量时,类似于
export class Component2 implements OnInit {
@Input() testVar;
somefunc() {
onUpload(testVar) {
console.log(testVar) ;
}
你能写一些例子或给我链接吗?问题是我想在没有 html 的 .ts 文件之间执行此操作。
【问题讨论】: