We have an angular2 component where we have certain radio buttons. I check the radio buttons on certain conditions.
The HTML code for radio buttons goes as:
<span class="radio-switch-group">
<label>
<input type="radio" name="radioView" id="All" (click)="onBtnClick('All')" [checked]="currentTab === 'All'">
<span class="radio-label">ALL Cars</span>
</label>
<label>
<input type="radio" name="radioView" id="Honda" (click)="onBtnClick('Honda')" [checked]="currentTab === 'Honda'">
<span class="radio-label">Honda</span>
</label>
</span>
The ts file is as follows:
export class CarComponent implements OnInit{
@Input() public currentTab: string = 'All';
public onBtnClick(carType: string){
this.currentTab = carType;
}
public ngOnInit() {
this.currentTab = 'All';
}
}
When I instantiate this component in a tab view from another component the radio button isnt checked even when the currentTab is set to 'All'