0

I am using angular material and ngx-form-schema in an angular 7 project. How can create a directive to handle all type of mat buttons? I want to send type of mat button such 'mat-flat-button' or 'mat-raised-button' to that directive then the directive show that mat button.

1 Answer 1

2

Create two buttons. One with mat-flat-button, one with mat-raised-button. Then use *ngIf or ngSwitch to display only one at a time.

Sign up to request clarification or add additional context in comments.

2 Comments

This may more than two button type needed. Is there generic method?
One way is to create a wrapper component which takes the type as an input, and in that component you use ngSwitch. A fancier solution would be to use ng-container and you can bind the type to the ngComponentOutlet attribute. If I'm correct, this way it also gets the component factories dynamically.

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.