yea2021
yea2021

Reputation: 77

Angular create my own attributes for a button element (not with ngClass or class)

I am using Angular 12 and I've created a button component which will contain a button element. I also know how to pass data using @Input, Output etc ... button what I need to do is to have something like Material UI for Angular does:

If I have this:

<button></button>

How can I wire the color class without using ngClass or Class but like this:

<button color="myclass"></button> ?

Upvotes: 0

Views: 1350

Answers (1)

vaira
vaira

Reputation: 2270

You can create an attribute directive for the button element, that internally does take input and applies it on the button.

attribute-directives

They have almost given the same example of what you need. : example

Upvotes: 2

Related Questions