Is it possible to pass a formControl ID / name as a string via a kendo switch on click function?

0 Answers 162 Views
Forms Switch
Olivia
Top achievements
Rank 1
Olivia asked on 03 Mar 2023, 01:49 PM

I'm struggling to access this kendo-switch ID (in this case it should be A1) being passed to the generateSubscriptionArray function it seems to return undefined no matter what variation of attempts to access it I try, it also doesn't seem to show up on the $event if I try to pass this to the function.

Any assistance regarding this would be really beneficial the switch is returning the relevant true/false boolean

HTML

 

<kendo-switch onLabel=" " offLabel=" " formControlName="A1" id="A1" (click)="generateSubscriptionArray(userPreferenceForm.controls.A1.value,
formcontrol id as string in this case A1 should be passed here)" ></kendo-switch>


TypeScript:

exportclass UserPreferencesComponent implements OnInit { userPreferenceForm: FormGroup; email_address: FormControl; constructor() {} ngOnInit(): void { this.userPreferenceForm = new FormGroup({ email_address: new FormControl('', Validators.required), A1: new FormControl(false), }); }

generateSubscriptionArray = (subscription: boolean, alertID: string): void => { if (subscription === true) { console.log(subscription, alertID); } else { console.log(subscription, alertID); } };


No answers yet. Maybe you can help?

Tags
Forms Switch
Asked by
Olivia
Top achievements
Rank 1
Share this question
or