Valid: {{vm.formValid}}
170 | 171 |173 | {{vm.formValue|json}} 174 |175 | -------------------------------------------------------------------------------- /src/app/components/purchase-form/purchase-form.component.scss: -------------------------------------------------------------------------------- 1 | :host { 2 | width: 100%; 3 | display: flex; 4 | flex-direction: column; 5 | align-items:center; 6 | p, ul { 7 | width: 500px; 8 | margin: 0px; 9 | padding: 0px; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/app/components/purchase-form/purchase-form.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, computed, effect, inject, signal, ViewChild } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ProductService } from '../../product.service'; 4 | import { toObservable, toSignal } from '@angular/core/rxjs-interop'; 5 | import { FormModel, formShape } from '../../models/form.model'; 6 | import { AddressComponent } from '../address/address.component'; 7 | import { debounceTime, filter, switchMap } from 'rxjs'; 8 | import { LukeService } from '../../luke.service'; 9 | import { PhonenumbersComponent } from '../phonenumbers/phonenumbers.component'; 10 | import { AddressModel } from '../../models/address.model'; 11 | import { templateDrivenForms } from '../../template-driven-forms/template-driven.forms'; 12 | import { validateShape } from '../../template-driven-forms/shape-validation'; 13 | import { createPurchaseValidationSuite } from '../../validations/purchase.validations'; 14 | import { SwapiService } from 'src/app/swapi.service'; 15 | 16 | @Component({ 17 | selector: 'sc-purchase-form', 18 | standalone: true, 19 | imports: [CommonModule, templateDrivenForms, AddressComponent, PhonenumbersComponent], 20 | templateUrl: './purchase-form.component.html', 21 | styleUrls: ['./purchase-form.component.scss'] 22 | }) 23 | export class PurchaseFormComponent { 24 | private readonly lukeService = inject(LukeService); 25 | private readonly swapiService = inject(SwapiService); 26 | private readonly productService = inject(ProductService); 27 | public readonly products = toSignal(this.productService.getAll()); 28 | protected readonly formValue = signal