I'm using radio buttons to display 2 options to the user, and based on their selection, they are routed to one of two components (one for each radio button). Any advice/ links on how to route to the desired destination based on their radio selection.
Template:
<app-radio-button
formControlName="collectionOption"
[groupName]="'collectionOption'"
[radioOptions]="radioOptions$ | async"
></app-radio-button>
Ts file:
ngOnInit() {
this.form = this.formBuilder.group({
collectionOption: ['', Validators.compose([Validators.required])],
});
this.form.valueChanges.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
if (this.form.valid) {
this.showGlobalError = false;
}
});
}
onContinueClick() {
this.isSubmitted = true;
if (this.form.valid || this.form.controls.collectionOption.value === this.postCard) {
this.router.navigateByUrl(this.radioOptionOneRoute);
} else {
this.showGlobalError = true;
}
}