[英]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.