Angular Material Dialog - 内容投影
创始人
2024-10-19 16:31:24
0

要在Angular Material Dialog中使用内容投影,您可以按照以下步骤进行操作:

  1. 首先,创建一个新的Angular组件,用于包装您的对话框内容。这个组件将负责对内容进行投影。
import { Component, OnInit, ContentChild, TemplateRef } from '@angular/core';

@Component({
  selector: 'app-dialog-content',
  template: `
    
  `
})
export class DialogContentComponent implements OnInit {
  @ContentChild(TemplateRef) content: TemplateRef;

  constructor() { }

  ngOnInit() {
  }

}
  1. 在您的对话框组件中,使用元素将内容投影到对应的位置。

  
    
      
      

This is the projected content

  1. 在对话框组件的模板中,使用组件包装要投影的内容,并将其放置在中。

  2. 最后,在您的对话框组件中使用组件的content模板引用。

import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
  selector: 'app-dialog-example',
  templateUrl: './dialog-example.component.html',
  styleUrls: ['./dialog-example.component.css']
})
export class DialogExampleComponent implements OnInit {

  constructor(
    public dialogRef: MatDialogRef,
    @Inject(MAT_DIALOG_DATA) public data: any
  ) { }

  ngOnInit() {
  }

}

这样,您就可以在Angular Material Dialog中使用内容投影了。注意,您可以将任何内容投影到对话框中,包括表单、按钮、文本等等。

相关内容

热门资讯

透视法门!拱趴大菠萝挂,pok... 透视法门!拱趴大菠萝挂,pokerworld软件(透视)好像真的是有透视脚本(哔哩哔哩)1、超多福利...
透视机巧!epoker底牌透视... 透视机巧!epoker底牌透视,cloudpoker怎么开挂(透视)都是存在有透视插件(哔哩哔哩)1...
透视练习!德普之星怎么设置埋牌... 透视练习!德普之星怎么设置埋牌,德普之星透视辅助软件(透视)确实有脚本方法(哔哩哔哩)1、让任何用户...
透视技法!wepoker怎么提... 透视技法!wepoker怎么提高运气,we poker辅助器下载(透视)竟然有脚本挂(哔哩哔哩)一、...
透视学习!hhpoker有没有... 透视学习!hhpoker有没有作必弊辅助,hh poker辅助器先试用(透视)竟然是有透视脚本(哔哩...
透视法子!德扑圈透视,德普之星... 透视法子!德扑圈透视,德普之星透视免费(透视)原来是真的透视工具(哔哩哔哩)1、德普之星透视免费公共...
透视经验!wepoker轻量版... 透视经验!wepoker轻量版透视方法,wepoker私人局规律(透视)一直是真的透视技巧(哔哩哔哩...
透视秘籍!wepoker免费辅... 透视秘籍!wepoker免费辅助器,wepoker怎么买辅助(透视)果然是真的脚本脚本(哔哩哔哩);...
透视学习!wepoker软件靠... 透视学习!wepoker软件靠谱么,wepoker透视有没有(透视)一直有透视脚本(哔哩哔哩)1、用...
透视绝活儿!德扑圈透视挂,德普... 透视绝活儿!德扑圈透视挂,德普之星私人局辅助免费(透视)竟然真的是有脚本工具(哔哩哔哩)1、德普之星...