I want to call showmodel(displayType)
from another compoent.How to call header component function to another component?
header.compoent.ts
You will need to use EventEmitter
.
@component({
selector:'app-header',
})
export class HeaderComponent {
public showmodel(displayType): void {
this.visible = true;
this.visibleAnimate = true
}
}
Now say in second component you emit the event on a button click.
@component({
selector:'another component',
template: ``
)
export class com2{
@Output() evt = new EventEmitter();
callShowModel(){
this.evt.emit();
}
}
Now your event can be hooked up in parent component