Angular - FormGroup.value zwraca undefined przy każdym FormControl

0

Witam.
Nie wiem dlaczego, ale wszystkie porady na forach, dokumentacji u mnie nie działają:

  frmCustomer = new FormGroup({
    code: new FormControl('', Validators.required),
    name: new FormControl('', Validators.required),
    firstName: new FormControl(''),
    lastName: new FormControl(''),
    street: new FormControl('', Validators.required),
    buildingNumber: new FormControl('', Validators.required),
    flatNumber: new FormControl(''),
    city: new FormControl('', Validators.required),
    description: new FormControl(''),
    vatNumber: new FormControl('', Validators.required)
  });

Nie ma znaczenia czy w konstruktorze, czy w ngOnInit(), czy nawet w ngAfterViewInit()

  ngOnInit() {
    const id = +this.activeRoute.snapshot.params['id'];
    if (id === 0) {
      this.pageTitle = 'NOWY KONTRAHENT';
      this.customer = new Customer();
    } else {
      this.pageTitle = 'EDYCJA KONTRAHENTA';
      this.customerService.GetById(id).subscribe((result: Customer) => {
        this.customer = result;
        this.frmCustomer.patchValue({
          code: this.customer.Code,
          name: this.customer.Name,
          firstName: this.customer.FirstName,
          lastName: this.customer.LastName,
          street: this.customer.Street,
          buildingNumber: this.customer.BuildingNumber,
          flatNumber: this.customer.FlatNumber,
          city: this.customer.City,
          description: this.customer.Description,
          vatNumber: this.customer.VatNumber
        });
      });
    }
  }

this.frmCustomer.value pokazuje dla wszystkich pól undefined. Próbowałem też za pomocą FormBuilder:

    this.frmCustomer = this._frmBuilder.group({
      code: new FormControl('', Validators.required),
      name: new FormControl('', Validators.required),
      firstName: new FormControl(''),
      lastName: new FormControl(''),
      street: new FormControl('', Validators.required),
      buildingNumber: new FormControl('', Validators.required),
      flatNumber: new FormControl(''),
      city: new FormControl('', Validators.required),
      description: new FormControl(''),
      vatNumber: new FormControl('', Validators.required)
    });

Walidatory działają, ponieważ input zmienia kolor, ale wartości są puste. Co robię źle? Coś nie działa?

Angular CLI: 8.3.5
Node: 10.16.3
Angular: 8.2.7
----------------------------------------------------
@angular-devkit/architect         0.803.5
@angular-devkit/build-angular     0.803.5
@angular-devkit/build-optimizer   0.803.5
@angular-devkit/build-webpack     0.803.5
@angular-devkit/core              8.3.5
@angular-devkit/schematics        8.3.5
@angular/cdk                      8.2.0
@angular/cli                      8.3.5
@angular/material                 8.2.0
@ngtools/webpack                  8.3.5
@schematics/angular               8.3.5
@schematics/update                0.803.5
rxjs                              6.5.3
typescript                        3.5.2
webpack                           4.39.2
1

Temat nieaktualny, wszystko działa w FormGroup oraz w FormControl. Propertki mojego modelu miał pierwszą wielką literę, a z API dostawałem w formacie camelCase, gdzie pierwsza jest mała litera...

Jest mi wstyd...

1 użytkowników online, w tym zalogowanych: 0, gości: 1