Guys thank you for your help. After getting lots of suggestions and mixed and matched all those suggested code I am able to solve the earlier issue. However I am getting the below error after using @ViewChild decorators in console.
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'count1'. Current value: 'count2'.
My Parent ts file code is following
import { Component, OnInit, Input, ViewEncapsulation, ViewChild, AfterViewInit} from '@angular/core';
import { NagivationComponent } from '../nagivation/nagivation.component';
import { CensusComponent } from '../your-data/census/census.component';
import { ApplicationComponent } from '../your-data/application/application.component';
@Component({
selector: 'app-your-data',
templateUrl: './your-data.component.html',
styleUrls: ['./your-data.component.css'],
encapsulation: ViewEncapsulation.None
})
export class YourDataComponent implements AfterViewInit{
@Input() step;
count:string = 'count1';
constructor() {
}
@ViewChild(CensusComponent, {static: false}) census: CensusComponent;
ngAfterViewInit() {
this.count = this.census.getSection();
}
}
And the your-data.component.html code is following
<div [ngSwitch]="count">
<app-census *ngSwitchCase="'count1'"></app-census>
<app-application *ngSwitchCase="'count2'"></app-application>
</div>