I made a shared table component that draws data according to the object passed using @Input() decorator. This is how my table looks like:
I tried to make whole table as abstract as possible, so every table in the project would be generated using only the passed parameters. This is the interface for menu items:
export interface IMenuItem {
icon: IconProp,
name: string,
action: Function
}
I pass array of IMenuItems and each has its own function that has to be executed when clicked. Now, when I pass a function that uses variables, functions, etc. that are outside its body, I get an error. Welp, the function gets executed separately and not in parent component so obviously it won't work that way. There's an example, when user clicks edit(pencil) icon, modal window should appear, for which I use separate function called "initModal".
editAct(data: any) {
console.log(data);
this.initModal(AddActComponent, "edit act", (res: any) => {
console.log(res);
})
}
My only idea is to pass those external functions too and use them as arguments for main function which then utilizes them accordingly, but if that outside function uses other variables, functions, etc. that I'm stuck again. I'd like to find better solution. So, if you have some advices I'd appreciate your help. Thanks.
