Compare commits
No commits in common. "bfda0985eb4c79f247246485f6ac110621c542bc" and "2c6fde0accb719567805a698908dba049c064337" have entirely different histories.
bfda0985eb
...
2c6fde0acc
|
@ -1,4 +1,3 @@
|
||||||
{
|
{
|
||||||
"singleQuote": true,
|
"singleQuote": true
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
}
|
||||||
|
|
18
angular.json
18
angular.json
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"projects": {
|
"projects": {
|
||||||
"contact": {
|
"contact-model": {
|
||||||
"root": "libs/contact",
|
"root": "libs/contact-model",
|
||||||
"sourceRoot": "libs/contact/src",
|
"sourceRoot": "libs/contact-model/src",
|
||||||
"projectType": "library",
|
"projectType": "library",
|
||||||
"schematics": {},
|
"schematics": {},
|
||||||
"architect": {
|
"architect": {
|
||||||
|
@ -11,18 +11,18 @@
|
||||||
"builder": "@angular-devkit/build-angular:tslint",
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
"options": {
|
"options": {
|
||||||
"tsConfig": [
|
"tsConfig": [
|
||||||
"libs/contact/tsconfig.lib.json",
|
"libs/contact-model/tsconfig.lib.json",
|
||||||
"libs/contact/tsconfig.spec.json"
|
"libs/contact-model/tsconfig.spec.json"
|
||||||
],
|
],
|
||||||
"exclude": ["**/node_modules/**", "!libs/contact/**"]
|
"exclude": ["**/node_modules/**", "!libs/contact-model/**"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"builder": "@nrwl/jest:jest",
|
"builder": "@nrwl/jest:jest",
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "libs/contact/jest.config.js",
|
"jestConfig": "libs/contact-model/jest.config.js",
|
||||||
"tsConfig": "libs/contact/tsconfig.spec.json",
|
"tsConfig": "libs/contact-model/tsconfig.spec.json",
|
||||||
"setupFile": "libs/contact/src/test-setup.ts"
|
"setupFile": "libs/contact-model/src/test-setup.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<ng-container *ngFor="let addr of addressArray?.controls">
|
|
||||||
<nested-forms-address [addressGroup]="addr"></nested-forms-address>
|
|
||||||
</ng-container>
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { AddressComponent } from './../address/address.component';
|
|
||||||
import { AddressListComponent } from './address-list.component';
|
|
||||||
|
|
||||||
describe('AddressListComponent', () => {
|
|
||||||
let component: AddressListComponent;
|
|
||||||
let fixture: ComponentFixture<AddressListComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [ReactiveFormsModule],
|
|
||||||
declarations: [ AddressListComponent, AddressComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AddressListComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
|
||||||
import { FormArray } from '@angular/forms';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'nested-forms-address-list',
|
|
||||||
templateUrl: './address-list.component.html',
|
|
||||||
styleUrls: ['./address-list.component.css']
|
|
||||||
})
|
|
||||||
export class AddressListComponent implements OnInit {
|
|
||||||
@Input() addressArray: FormArray;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
<form *ngIf="addressGroup" [formGroup]="addressGroup">
|
|
||||||
<div>
|
|
||||||
<label for="line1">Line 1: </label>
|
|
||||||
<input name="line1" formControlName="line1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="line2">Line 2: </label>
|
|
||||||
<input name="line2" formControlName="line2">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="city">City: </label>
|
|
||||||
<input name="city" formControlName="city">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="state">State: </label>
|
|
||||||
<input name="state" formControlName="state">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="postalCode">Postal Code: </label>
|
|
||||||
<input name="postalCode" formControlName="postalCode">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { AddressComponent } from './address.component';
|
|
||||||
|
|
||||||
describe('AddressComponent', () => {
|
|
||||||
let component: AddressComponent;
|
|
||||||
let fixture: ComponentFixture<AddressComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [ReactiveFormsModule],
|
|
||||||
declarations: [ AddressComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AddressComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
|
||||||
import { FormGroup } from '@angular/forms';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'nested-forms-address',
|
|
||||||
templateUrl: './address.component.html',
|
|
||||||
styleUrls: ['./address.component.css']
|
|
||||||
})
|
|
||||||
export class AddressComponent implements OnInit {
|
|
||||||
@Input() addressGroup: FormGroup;
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form">
|
||||||
<nested-forms-name [nameGroup]="form.get('nameGroup')"></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>
|
|
||||||
</form>
|
</form>
|
||||||
<hr />
|
<hr />
|
||||||
<pre>
|
<pre>
|
||||||
|
|
|
@ -3,21 +3,12 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { TestBed, async } from '@angular/core/testing';
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { NameComponent } from './name/name.component';
|
import { NameComponent } from './name/name.component';
|
||||||
import { AddressListComponent } from './address-list/address-list.component';
|
|
||||||
import { AddressComponent } from './address/address.component';
|
|
||||||
import { ContactModule } from '@nested-forms/contact';
|
|
||||||
import { ContactFormService } from './services/contact-form.service';
|
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [RouterTestingModule, ReactiveFormsModule],
|
||||||
RouterTestingModule,
|
declarations: [AppComponent, NameComponent]
|
||||||
ReactiveFormsModule,
|
|
||||||
ContactModule.forRoot()
|
|
||||||
],
|
|
||||||
declarations: [AppComponent, NameComponent, AddressComponent, AddressListComponent],
|
|
||||||
providers: [ ContactFormService ],
|
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -26,4 +17,5 @@ describe('AppComponent', () => {
|
||||||
const app = fixture.debugElement.componentInstance;
|
const app = fixture.debugElement.componentInstance;
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,37 +1,23 @@
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { Component } from '@angular/core';
|
||||||
import { Contact, ContactService } from '@nested-forms/contact';
|
|
||||||
import { Subscription } from 'rxjs';
|
|
||||||
import { ContactFormService } from './services/contact-form.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'nested-forms-root',
|
selector: 'nested-forms-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.css'],
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent {
|
||||||
contact: Contact;
|
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
|
|
||||||
private subscription: Subscription;
|
constructor(private fb: FormBuilder) {
|
||||||
|
this.form = this.fb.group({
|
||||||
constructor(
|
nameGroup: this.fb.group({
|
||||||
private service: ContactService,
|
firstName: [], // new FormControl(this.name ? this.name.firstName : ''),
|
||||||
private formService: ContactFormService,
|
lastName: [], // new FormControl(this.name ? this.name.lastName : ''),
|
||||||
) {}
|
middleName: [], // new FormControl(this.name ? this.name.middleName : ''),
|
||||||
|
prefix: [], // new FormControl(this.name ? this.name.prefix : ''),
|
||||||
public ngOnInit() {
|
suffix: [], // new FormControl(this.name ? this.name.suffix : ''),
|
||||||
this.subscription = this.service
|
})
|
||||||
.loadContact()
|
});
|
||||||
.subscribe((data: Contact) => {
|
|
||||||
this.contact = data;
|
|
||||||
this.form = this.formService.createForm(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
|
||||||
if (this.subscription) {
|
|
||||||
this.subscription.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,13 @@ import { AppComponent } from './app.component';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NameComponent } from './name/name.component';
|
import { NameComponent } from './name/name.component';
|
||||||
import { ContactModule } from '@nested-forms/contact';
|
|
||||||
import { AddressListComponent } from './address-list/address-list.component';
|
|
||||||
import { AddressComponent } from './address/address.component';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent],
|
declarations: [AppComponent, NameComponent],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
RouterModule.forRoot([], { initialNavigation: 'enabled' }),
|
RouterModule.forRoot([], { initialNavigation: 'enabled' }),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule
|
||||||
ContactModule.forRoot()
|
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|
|
@ -1,27 +1 @@
|
||||||
<form *ngIf="nameGroup" [formGroup]="nameGroup">
|
<p>name works!</p>
|
||||||
<div>
|
|
||||||
<label for="firstName">First Name: </label>
|
|
||||||
<input name="firstName" formControlName="firstName">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="lastName">Last Name: </label>
|
|
||||||
<input name="lastName" formControlName="lastName">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="middleName">Middle Name: </label>
|
|
||||||
<input name="middleName" formControlName="middleName">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="prefix">Prefix: </label>
|
|
||||||
<input name="prefix" formControlName="prefix">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="suffix">Suffix: </label>
|
|
||||||
<input name="suffix" formControlName="suffix">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { NameComponent } from './name.component';
|
import { NameComponent } from './name.component';
|
||||||
|
|
||||||
|
@ -9,7 +8,6 @@ describe('NameComponent', () => {
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ReactiveFormsModule],
|
|
||||||
declarations: [NameComponent]
|
declarations: [NameComponent]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
|
|
||||||
import { ContactFormService } from './contact-form.service';
|
|
||||||
|
|
||||||
describe('ContactFormService', () => {
|
|
||||||
beforeEach(() => TestBed.configureTestingModule({
|
|
||||||
imports: [ReactiveFormsModule],
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
const service: ContactFormService = TestBed.get(ContactFormService);
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
|
||||||
import { Contact } from '@nested-forms/contact';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class ContactFormService {
|
|
||||||
constructor(private fb: FormBuilder) {}
|
|
||||||
|
|
||||||
public createForm(model: Contact): FormGroup {
|
|
||||||
const name = model.name;
|
|
||||||
|
|
||||||
const addresses: FormArray = this.fb.array([]);
|
|
||||||
|
|
||||||
const group = this.fb.group({
|
|
||||||
nameGroup: this.fb.group({
|
|
||||||
firstName: [name ? name.firstName : ''],
|
|
||||||
lastName: [name ? name.lastName : ''],
|
|
||||||
middleName: [name ? name.middleName : ''],
|
|
||||||
prefix: [name ? name.prefix : ''],
|
|
||||||
suffix: [name ? name.suffix : ''],
|
|
||||||
}),
|
|
||||||
addresses: addresses,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (model.addresses) {
|
|
||||||
model.addresses.forEach(addr => {
|
|
||||||
addresses.push(
|
|
||||||
this.fb.group({
|
|
||||||
line1: [addr ? addr.line_1 : ''],
|
|
||||||
line2: [addr ? addr.line_2 : ''],
|
|
||||||
city: [addr ? addr.city : ''],
|
|
||||||
state: [addr ? addr.state : ''],
|
|
||||||
postalCode: [addr ? addr.postalCode : ''],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
||||||
import { Address } from '@nested-forms/contact';
|
import { Address } from '@nested-forms/contact-model';
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FormArray, FormBuilder, FormGroup, FormControl } from '@angular/forms';
|
import { FormArray, FormBuilder, FormGroup, FormControl } from '@angular/forms';
|
||||||
import { Address } from '@nested-forms/contact';
|
import { Address } from '@nested-forms/contact-model';
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -5,12 +5,11 @@ import { AppComponent } from './app.component';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NameComponent } from './name/name.component';
|
import { NameComponent } from './name/name.component';
|
||||||
import { ContactModule } from '@nested-forms/contact';
|
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [RouterTestingModule, ReactiveFormsModule, ContactModule.forRoot()],
|
imports: [RouterTestingModule, ReactiveFormsModule],
|
||||||
declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent]
|
declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Contact, ContactService } from '@nested-forms/contact';
|
import { ContactService } from './../../../../libs/contact-model/src/lib/contact.service';
|
||||||
|
import { Contact } from '@nested-forms/contact-model';
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NameComponent } from './name/name.component';
|
import { NameComponent } from './name/name.component';
|
||||||
import { AddressListComponent } from './address-list/address-list.component';
|
import { AddressListComponent } from './address-list/address-list.component';
|
||||||
import { AddressComponent } from './address/address.component';
|
import { AddressComponent } from './address/address.component';
|
||||||
import { ContactModule } from '@nested-forms/contact';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent],
|
declarations: [AppComponent, NameComponent, AddressListComponent, AddressComponent],
|
||||||
|
@ -15,7 +14,6 @@ import { ContactModule } from '@nested-forms/contact';
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
RouterModule.forRoot([], { initialNavigation: 'enabled' }),
|
RouterModule.forRoot([], { initialNavigation: 'enabled' }),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
ContactModule.forRoot(),
|
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
|
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
|
||||||
import { Name } from '@nested-forms/contact';
|
import { Name } from '@nested-forms/contact-model';
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -107,7 +107,6 @@ module.exports = {
|
||||||
|
|
||||||
// A path to a custom resolver
|
// A path to a custom resolver
|
||||||
// resolver: null,
|
// resolver: null,
|
||||||
resolver: '@nrwl/jest/plugins/resolver',
|
|
||||||
|
|
||||||
// Automatically restore mock state between every test
|
// Automatically restore mock state between every test
|
||||||
// restoreMocks: false,
|
// restoreMocks: false,
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# contact-model
|
||||||
|
|
||||||
|
This library was generated with [Nx](https://nx.dev).
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `ng test contact-model` to execute the unit tests via [Jest](https://jestjs.io).
|
|
@ -1,9 +1,9 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'contact',
|
name: 'contact-model',
|
||||||
preset: '../../jest.config.js',
|
preset: '../../jest.config.js',
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.[tj]sx?$': 'ts-jest'
|
'^.+\\.[tj]sx?$': 'ts-jest'
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
coverageDirectory: '../../coverage/libs/contact',
|
coverageDirectory: '../../coverage/libs/contact-model',
|
||||||
};
|
};
|
|
@ -1,3 +1,2 @@
|
||||||
export * from './lib/contact-model';
|
export * from './lib/contact-model';
|
||||||
export * from './lib/contact.service';
|
export * from './lib/contact.service';
|
||||||
export * from './lib/contact.module';
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Contact } from './contact-model';
|
import { Contact } from '@nested-forms/contact-model';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
|
|
||||||
const contact: Contact = {
|
const contact: Contact = {
|
||||||
|
@ -27,7 +27,9 @@ const contact: Contact = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
export class ContactService {
|
export class ContactService {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# contact
|
|
||||||
|
|
||||||
This library was generated with [Nx](https://nx.dev).
|
|
||||||
|
|
||||||
## Running unit tests
|
|
||||||
|
|
||||||
Run `ng test contact` to execute the unit tests via [Jest](https://jestjs.io).
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { NgModule, Optional, SkipSelf } from '@angular/core';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { ContactService } from './contact.service';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [],
|
|
||||||
imports: [
|
|
||||||
CommonModule
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export class ContactModule {
|
|
||||||
constructor(
|
|
||||||
@Optional()
|
|
||||||
@SkipSelf()
|
|
||||||
parentModule: ContactModule
|
|
||||||
) {
|
|
||||||
if (parentModule) {
|
|
||||||
throw new Error('ContactModule is already loaded. Import it in the AppModule only');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static forRoot() {
|
|
||||||
return {
|
|
||||||
ngModule: ContactModule,
|
|
||||||
providers: [ ContactService ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
nx.json
2
nx.json
|
@ -8,7 +8,7 @@
|
||||||
"nx.json": "*"
|
"nx.json": "*"
|
||||||
},
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"contact": {
|
"contact-model": {
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"parent-form-e2e": {
|
"parent-form-e2e": {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@nested-forms/contact": ["libs/contact/src/index.ts"]
|
"@nested-forms/contact-model": ["libs/contact-model/src/index.ts"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "tmp"]
|
"exclude": ["node_modules", "tmp"]
|
||||||
|
|
Loading…
Reference in New Issue