Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

app.component.ts

28 lines843 Bytes

1import { ChangeDetectionStrategy, Component, signal } from '@angular/core'
2import { injectForm } from '@tanstack/angular-form'
3import { StepOneComponent } from './step-one.component'
4import { StepTwoComponent } from './step-two.component'
5import { wizardFormOptions } from './shared-form'
6​
7@Component({
8 selector: 'app-root',
9 standalone: true,
10 changeDetection: ChangeDetectionStrategy.OnPush,
11 imports: [StepOneComponent, StepTwoComponent],
12 template: `
13 <main>
14 <h1>Multi-step Wizard</h1>
15 @if (step() === 0) {
16 <app-step-one [form]="form" [advance]="advance" />
17 } @else {
18 <app-step-two [form]="form" [back]="back" />
19 }
20 </main>
21 `,
22})
23export class AppComponent {
24 step = signal(0)
25 form = injectForm(wizardFormOptions)
26 advance = () => this.step.set(1)
27 back = () => this.step.set(0)