0

I was wondering how it would be possible for me to create a custom Angular component that was based off of the native HTML button element and contained its own disabled property.

We currently have our own implementation of the button element that does not contain a disabled property and I wanted to know how I can add this functionality and make sure that it remains unusable and un-clickable.

Thanks

1 Answer 1

1
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/>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, that makes sense. Out of curiosity, if you are planning on extending some native HTML elements functionality, would you normally just wrap your component around it and add to it?
actually, not :) you can use [disabled]="true" (or false) directly on button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.