繁体   English   中英

创建具有禁用属性的自定义角度按钮组件

[英]Creating Custom Angular Button Component with Disabled Attribute

我想知道如何创建一个自定义Angular组件,该组件基于本机HTML button元素并包含其自己的disabled属性。

当前,我们有自己的button元素实现,其中不包含disabled属性,我想知道如何添加此功能并确保它保持不可用和不可点击状态。

谢谢

import { Component, Input } from '@angular/core';

@Component({
  selector: 'my-button',
  template: `<button [disabled]="disabledValue">button</button>`
})
export class MyButtonComponent  {
@Input()
public disabledValue: boolean;
}
//usage: <my-button [disabledValue]="true"><my-button/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM