如何访问角形材料组件的属性? [英] How to access properties of angular material components?

查看:84
本文介绍了如何访问角形材料组件的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般来说,我对Angle还是比较陌生,我已经用它构建了我的前几个应用程序,现在我正在从事一些包含Angle材质的项目.

当我转到网站时,我看到了MatSelect指令的许多属性.我想以某种方式访问​​一个称为空:布尔值"的属性,但我不知道如何,您能帮我吗?

解决方案

请注意导出为:matSelect .您可以通过模板引用变量(#var)或ViewChild来引用它:

 < mat-select #matSelect ='matSelect'>... 

component.ts:

  @ViewChild('matSelect')子级:MatSelect;//或者@ViewChild(MatSelect)子对象:MatSelect; 

https://material.angular.io/components/select/api#MatSelect

演示示例

I'm fairly new to angular in general, i have built my first few apps with it and right now I'm working on some project that contains angular material.

When i go to this site i see lots of properties of the MatSelect directive. There is one property called 'empty: boolean' that I would like to access in some way, but i don't know how, can you help me?

解决方案

Pay attention to Exported as:matSelect. You can reference it by template reference variable(#var) or by ViewChild:

  <mat-select #matSelect = 'matSelect'>
  ...

component.ts:

   @ViewChild('matSelect') child: MatSelect; 
   //or
   @ViewChild(MatSelect) child: MatSelect; 

https://material.angular.io/components/select/api#MatSelect

Demo Example

这篇关于如何访问角形材料组件的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆