Skip to content

Commit 1db35be

Browse files
Update static/usage/v8/toggle/helper-error/angular/example_component_ts.md
Co-authored-by: Brandy Smith <[email protected]>
1 parent 46dbaef commit 1db35be

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

static/usage/v8/toggle/helper-error/angular/example_component_ts.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
```ts
22
import { Component } from '@angular/core';
3-
import { FormBuilder, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
4-
import { IonToggle, IonButton } from '@ionic/angular/standalone';
3+
import {
4+
FormBuilder,
5+
FormGroup,
6+
Validators,
7+
ReactiveFormsModule,
8+
} from '@angular/forms';
9+
import { IonToggle } from '@ionic/angular/standalone';
510

611
@Component({
712
selector: 'app-example',
813
standalone: true,
9-
imports: [IonToggle, IonButton, ReactiveFormsModule],
14+
imports: [IonToggle, ReactiveFormsModule],
1015
templateUrl: './example.component.html',
1116
styleUrl: './example.component.css',
1217
})
@@ -15,14 +20,13 @@ export class ExampleComponent {
1520

1621
constructor(private fb: FormBuilder) {
1722
this.myForm = this.fb.group({
18-
wifi: [false, Validators.requiredTrue],
23+
wifi: [true, Validators.requiredTrue],
1924
});
2025
}
2126

22-
onSubmit() {
23-
// Mark the control as touched to trigger the error message.
24-
// This is needed if the user submits the form without interacting
25-
// with the toggle.
27+
onChange() {
28+
// Mark the control as touched to trigger the error message
29+
// without requiring the toggle to be blurred first
2630
this.myForm.get('wifi')!.markAsTouched();
2731
}
2832
}

0 commit comments

Comments
 (0)