I am new at Angular so in order to learn it I always create a small project. In this case I have 3 components of which only these two are important for now:
TANavBarComponentTAPageContainerComponent
In my TANavBarComponent I want to 'Output' the selected Tab and use that value as 'Input' in TAPageContainerComponent. Based on the input received I will 'fill' the container with the 3rd component.
My code for TANavBarComponent:
export class TANavBarComponent {
@Output() pageToDisplay = new EventEmitter();
tabClick(pageName: string){
switch(pageName){
case '1':
alert(pageName);
this.pageToDisplay.emit(pageName);
break;
case '2':
alert(pageName);
this.pageToDisplay.emit(pageName);
break;
}
}
}
My code for TAPageContainerComponent:
export class TAPageContainerComponent {
title: string = "TAPageContainerComponent";
@Input() pageToDisplay!: string;
}
<div [ngSwitch]={pageToDisplay} class="ta-page-container" >
<div *ngSwitchCase="'1'"><clone-user-settings></clone-user-settings></div>
<div *ngSwitchCase="'2'"><transfer-deal></transfer-deal></div>
</div>
How do I get the 'Output' as 'Input' in order to perform the NgSwich?