Compare commits

..

No commits in common. "2bf76e87c8c04add1bc714b93f5de72df6115dcd" and "1df633dacd44b425af728dfff92ee5f1a2ce6cb3" have entirely different histories.

8 changed files with 19 additions and 21 deletions

View File

@ -1,5 +1,5 @@
<form *ngIf="form" [formGroup]="form"> <form *ngIf="form" [formGroup]="form">
<ng-container formGroupName="name"> <ng-container formGroupName="nameGroup">
<div> <div>
<label for="firstName">First Name: </label> <label for="firstName">First Name: </label>
<input name="firstName" formControlName="firstName"> <input name="firstName" formControlName="firstName">

View File

@ -1,5 +1,5 @@
<form [formGroup]="form"> <form [formGroup]="form">
<nested-forms-name [nameGroup]="form.get('name')"></nested-forms-name> <nested-forms-name [nameGroup]="form.get('nameGroup')"></nested-forms-name>
<nested-forms-address-list [addressArray]="form.get('addresses')"></nested-forms-address-list> <nested-forms-address-list [addressArray]="form.get('addresses')"></nested-forms-address-list>
</form> </form>
<hr /> <hr />

View File

@ -1,4 +1,4 @@
export * from './lib/contact-model'; export * from './lib/contact-model';
export * from './lib/services/contact.service'; export * from './lib/contact.service';
export * from './lib/services/contact-form.service'; export * from './lib/services/contact-form.service';
export * from './lib/contact.module'; export * from './lib/contact.module';

View File

@ -1,20 +1,20 @@
export interface Name { export interface Name {
firstName: string; firstName?: string;
lastName: string; lastName?: string;
middleName: string; middleName?: string;
prefix: string; prefix?: string;
suffix: string; suffix?: string;
} }
export interface Address { export interface Address {
line_1: string; line_1?: string;
line_2: string; line_2?: string;
city: string; city?: string;
state: string; state?: string;
postalCode: string; postalCode?: string;
} }
export interface Contact { export interface Contact {
name: Name; name?: Name;
addresses: Address[]; addresses?: Address[];
} }

View File

@ -1,6 +1,6 @@
import { NgModule, Optional, SkipSelf } from '@angular/core'; import { NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ContactService } from './services/contact.service'; import { ContactService } from './contact.service';
import { ContactFormService } from './services/contact-form.service'; import { ContactFormService } from './services/contact-form.service';
@NgModule({ @NgModule({

View File

@ -1,4 +1,4 @@
import { Contact } from '../contact-model'; import { Contact } from './contact-model';
import { TestBed, async } from '@angular/core/testing'; import { TestBed, async } from '@angular/core/testing';
import { ContactService } from './contact.service'; import { ContactService } from './contact.service';

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Contact } from '../contact-model'; import { Contact } from './contact-model';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
const contact: Contact = { const contact: Contact = {
@ -14,14 +14,12 @@ const contact: Contact = {
addresses: [ addresses: [
{ {
line_1: '123 Main Street', line_1: '123 Main Street',
line_2: null,
city: 'New York', city: 'New York',
state: 'NY', state: 'NY',
postalCode: '12345', postalCode: '12345',
}, },
{ {
line_1: '123 South Street', line_1: '123 South Street',
line_2: null,
city: 'Boston', city: 'Boston',
state: 'MA', state: 'MA',
postalCode: '54321', postalCode: '54321',

View File

@ -14,7 +14,7 @@ export class ContactFormService {
const addresses: FormArray = this.fb.array([]); const addresses: FormArray = this.fb.array([]);
const group = this.fb.group({ const group = this.fb.group({
name: this.fb.group({ nameGroup: this.fb.group({
firstName: [name ? name.firstName : ''], firstName: [name ? name.firstName : ''],
lastName: [name ? name.lastName : ''], lastName: [name ? name.lastName : ''],
middleName: [name ? name.middleName : ''], middleName: [name ? name.middleName : ''],