I am developing an Angular application based on PrimeNG UI library. It implements several pages which contain tables, for example UsersComponent, AccountsComponent, TweetsComponent, etc.
I am using PrimeNG's Table component to display the data in table form. In order to achieve component reusability, I have created a generic TableComponent class which implements PrimeNG table, and have added custom functionality to this table component like filters, sorting, etc.
I can pass data from UsersComponent, AccountsComponent, and TweetsComponent to this TableComponent and the data from these parent components is displayed nicely like I want.
<UsersComponent>
<TableComponent [data]="usersArray"></TableComponent>
</UsersComponent>
<AccountsComponent>
<TableComponent [data]="accountsArray"></TableComponent>
</AccountsComponent>
<TweetsComponent>
<TableComponent [data]="tweetsArray"></TableComponent>
</TweetsComponent>
However, the issue is that I want to add some methods that are specific to each component. For example, when the TableComponent is displaying list of users, I want to be able to call methods addUser(), deleteUser() and updateUser() that add, delete or update a user record, respectively. Similarly, AccountsComponent should have its own functionality and separate, independent API calls.
How can I achieve this in Angular?
I can pass down data from parent to child component but how can I pass multiple specific methods to the child? Where will I create these methods and how shall I call them in the child component?