Hello, I have a somewhat complicated challenge for me.
I need to create a generic form, where I pass a list of inputs and a list of buttons and my component performs the hard work, like presenting messages, putting on masks etc.
The list of inputs I was able to create normally, but I packed the button list.
I need to leave this form genius, so I can not limit the amount of buttons, I really need to pass a list to my compoenent, so I perform a * ngFor and distribute my list of buttons. In relation to that I can perform also, very calm. My problem is:
Let's suppose that in this list of buttons I have 2 buttons.
And in my parent component I have 2 methods: method1 and method2.
I need to find a way to click on my button1 of the generic form, it fires my method1 from the parent component, and if I click on my button2, it fires method2 from my parent component, and so on, according to the amount of buttons present in that list.
I tried to do with EventEmitter, but I can not build a list using it, because every new button in the list would have to add an @Output () in the compoenent.ts of the child.
Does anyone know a way to do this?
Thank you in advance ...
Edited question to requests in comments.
Adding the component.ts and component.html of the form.
In the component.ts I add to the buttons only the code below, passing a list of buttons and getting that way.
@Input () ListBoxes: BotoesModel [];
In my html already, I just do a * ngFor this way below:
<div *ngFor='let button of listaDeBotoes' class="{{container_btn_class}}">
<button class="{{button.classStyle}} {{btn_class}}">{{button?.nome}}</button>
</div>