I have two components Main
(parent) and Header
(child). I want to add buttons in my Header
component from the Main
component. Clicking the button should change a state in my Main
component. I don't want it to be hardcoded, but rather passing an Array of objects from Main
component to Header
component. Clicking the button in header should trigger a state change in my Main
component. I know how to do it by using @Input
and @Output
decorators using EventEmitters
, however i want to provide like a callback function in the array object to call in my parent component. Is it possible to do?
Sorry if this sounds little weird - i dont know how else to explain it :) Here is a prototype of the Array i want to pass:
headerButtons: Array<any> = [{title: 'Button 1', callback: 'callbackMethod1'}, {title: 'Button 2', callback: 'callbackMethod2'}];