├── reactive-forms ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── registration.service.spec.ts │ │ ├── registration.service.ts │ │ └── shared │ │ │ ├── password.validator.ts │ │ │ └── user-name.validator.ts │ ├── assets │ │ └── .gitkeep │ ├── browserslist │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── karma.conf.js │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ ├── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ └── tslint.json ├── tsconfig.json └── tslint.json ├── server ├── .gitignore ├── package-lock.json ├── package.json └── server.js └── template-driven-forms ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── src ├── app │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── enrollment.service.spec.ts │ ├── enrollment.service.ts │ └── user.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json └── tslint.json /reactive-forms/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /reactive-forms/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /reactive-forms/README.md: -------------------------------------------------------------------------------- 1 | # ReactiveForms 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.8. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /reactive-forms/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "reactive-forms": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/reactive-forms", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "fileReplacements": [ 33 | { 34 | "replace": "src/environments/environment.ts", 35 | "with": "src/environments/environment.prod.ts" 36 | } 37 | ], 38 | "optimization": true, 39 | "outputHashing": "all", 40 | "sourceMap": false, 41 | "extractCss": true, 42 | "namedChunks": false, 43 | "aot": true, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true 47 | } 48 | } 49 | }, 50 | "serve": { 51 | "builder": "@angular-devkit/build-angular:dev-server", 52 | "options": { 53 | "browserTarget": "reactive-forms:build" 54 | }, 55 | "configurations": { 56 | "production": { 57 | "browserTarget": "reactive-forms:build:production" 58 | } 59 | } 60 | }, 61 | "extract-i18n": { 62 | "builder": "@angular-devkit/build-angular:extract-i18n", 63 | "options": { 64 | "browserTarget": "reactive-forms:build" 65 | } 66 | }, 67 | "test": { 68 | "builder": "@angular-devkit/build-angular:karma", 69 | "options": { 70 | "main": "src/test.ts", 71 | "polyfills": "src/polyfills.ts", 72 | "tsConfig": "src/tsconfig.spec.json", 73 | "karmaConfig": "src/karma.conf.js", 74 | "styles": [ 75 | "src/styles.css" 76 | ], 77 | "scripts": [], 78 | "assets": [ 79 | "src/favicon.ico", 80 | "src/assets" 81 | ] 82 | } 83 | }, 84 | "lint": { 85 | "builder": "@angular-devkit/build-angular:tslint", 86 | "options": { 87 | "tsConfig": [ 88 | "src/tsconfig.app.json", 89 | "src/tsconfig.spec.json" 90 | ], 91 | "exclude": [ 92 | "**/node_modules/**" 93 | ] 94 | } 95 | } 96 | } 97 | }, 98 | "reactive-forms-e2e": { 99 | "root": "e2e/", 100 | "projectType": "application", 101 | "architect": { 102 | "e2e": { 103 | "builder": "@angular-devkit/build-angular:protractor", 104 | "options": { 105 | "protractorConfig": "e2e/protractor.conf.js", 106 | "devServerTarget": "reactive-forms:serve" 107 | }, 108 | "configurations": { 109 | "production": { 110 | "devServerTarget": "reactive-forms:serve:production" 111 | } 112 | } 113 | }, 114 | "lint": { 115 | "builder": "@angular-devkit/build-angular:tslint", 116 | "options": { 117 | "tsConfig": "e2e/tsconfig.e2e.json", 118 | "exclude": [ 119 | "**/node_modules/**" 120 | ] 121 | } 122 | } 123 | } 124 | } 125 | }, 126 | "defaultProject": "reactive-forms" 127 | } -------------------------------------------------------------------------------- /reactive-forms/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /reactive-forms/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to reactive-forms!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /reactive-forms/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /reactive-forms/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /reactive-forms/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactive-forms", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "^6.0.3", 15 | "@angular/common": "^6.0.3", 16 | "@angular/compiler": "^6.0.3", 17 | "@angular/core": "^6.0.3", 18 | "@angular/forms": "^6.0.3", 19 | "@angular/http": "^6.0.3", 20 | "@angular/platform-browser": "^6.0.3", 21 | "@angular/platform-browser-dynamic": "^6.0.3", 22 | "@angular/router": "^6.0.3", 23 | "core-js": "^2.5.4", 24 | "rxjs": "^6.0.0", 25 | "zone.js": "^0.8.26" 26 | }, 27 | "devDependencies": { 28 | "@angular/compiler-cli": "^6.0.3", 29 | "@angular-devkit/build-angular": "~0.6.8", 30 | "typescript": "~2.7.2", 31 | "@angular/cli": "~6.0.8", 32 | "@angular/language-service": "^6.0.3", 33 | "@types/jasmine": "~2.8.6", 34 | "@types/jasminewd2": "~2.0.3", 35 | "@types/node": "~8.9.4", 36 | "codelyzer": "~4.2.1", 37 | "jasmine-core": "~2.99.1", 38 | "jasmine-spec-reporter": "~4.2.1", 39 | "karma": "~1.7.1", 40 | "karma-chrome-launcher": "~2.2.0", 41 | "karma-coverage-istanbul-reporter": "~2.0.0", 42 | "karma-jasmine": "~1.1.1", 43 | "karma-jasmine-html-reporter": "^0.2.2", 44 | "protractor": "~5.3.0", 45 | "ts-node": "~5.0.1", 46 | "tslint": "~5.9.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /reactive-forms/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/reactive-forms/src/app/app.component.css -------------------------------------------------------------------------------- /reactive-forms/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Registration Form

3 | 4 |
5 |
6 | 7 | 8 | 9 |
10 | Username is required 11 | Username must be at least 3 characters 12 | '{{userName.errors?.forbiddenName.value}}' username not allowed 13 |
14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 |
22 | 23 | 24 | Passwords do not match 25 |
26 | 27 |
28 | 29 | 30 | 31 | Email is required 32 |
33 | 34 |
35 |
36 | 37 |
38 | 39 | 42 |
43 | 44 |
45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 |
55 | 56 |
57 | 58 | 59 |
60 | 61 |
62 | 63 | 64 | 65 | 66 |
67 | 68 | {{registrationForm.status | json}} 69 | {{registrationForm.value | json}} 70 |
71 | -------------------------------------------------------------------------------- /reactive-forms/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to reactive-forms!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /reactive-forms/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormGroup, FormControl, FormArray, Validators } from '@angular/forms'; 3 | import { FormBuilder } from '@angular/forms'; 4 | import { ForbiddenNameValidator } from './shared/user-name.validator'; 5 | import { PasswordValidator } from './shared/password.validator'; 6 | import { RegistrationService } from './registration.service'; 7 | 8 | @Component({ 9 | selector: 'app-root', 10 | templateUrl: './app.component.html', 11 | styleUrls: ['./app.component.css'] 12 | }) 13 | export class AppComponent implements OnInit { 14 | 15 | registrationForm: FormGroup; 16 | // registrationForm = new FormGroup({ 17 | // userName: new FormControl('Vishwas'), 18 | // password: new FormControl(''), 19 | // confirmPassword: new FormControl(''), 20 | // address: new FormGroup({ 21 | // city: new FormControl(''), 22 | // state: new FormControl(''), 23 | // postalCode: new FormControl('') 24 | // }) 25 | // }); 26 | constructor(private fb: FormBuilder, private _registrationService: RegistrationService) { } 27 | 28 | ngOnInit() { 29 | this.registrationForm = this.fb.group({ 30 | userName: ['', [Validators.required, Validators.minLength(3), ForbiddenNameValidator(/password/)]], 31 | password: [''], 32 | confirmPassword: [''], 33 | email: [''], 34 | subscribe: [false], 35 | address: this.fb.group({ 36 | city: [''], 37 | state: [''], 38 | postalCode: [''] 39 | }), 40 | alternateEmails: this.fb.array([]) 41 | }, { validator: PasswordValidator }); 42 | 43 | this.registrationForm.get('subscribe').valueChanges 44 | .subscribe(checkedValue => { 45 | const email = this.registrationForm.get('email'); 46 | if (checkedValue) { 47 | email.setValidators(Validators.required); 48 | } else { 49 | email.clearValidators(); 50 | } 51 | email.updateValueAndValidity(); 52 | }); 53 | } 54 | 55 | get userName() { 56 | return this.registrationForm.get('userName'); 57 | } 58 | 59 | get email() { 60 | return this.registrationForm.get('email'); 61 | } 62 | 63 | get alternateEmails() { 64 | return this.registrationForm.get('alternateEmails') as FormArray; 65 | } 66 | 67 | addAlternateEmail() { 68 | this.alternateEmails.push(this.fb.control('')); 69 | } 70 | 71 | loadAPIData() { 72 | // this.registrationForm.setValue({ 73 | // userName: 'Bruce', 74 | // password: 'test', 75 | // confirmPassword: 'test', 76 | // address: { 77 | // city: 'City', 78 | // state: 'State', 79 | // postalCode: '123456' 80 | // } 81 | // }); 82 | 83 | this.registrationForm.patchValue({ 84 | userName: 'Bruce', 85 | password: 'test', 86 | confirmPassword: 'test' 87 | }); 88 | } 89 | 90 | onSubmit() { 91 | console.log(this.registrationForm.value); 92 | this._registrationService.register(this.registrationForm.value) 93 | .subscribe( 94 | response => console.log('Success!', response), 95 | error => console.error('Error!', error) 96 | ); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /reactive-forms/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { ReactiveFormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http'; 5 | import { AppComponent } from './app.component'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | BrowserModule, 13 | ReactiveFormsModule, 14 | HttpClientModule 15 | ], 16 | providers: [], 17 | bootstrap: [AppComponent] 18 | }) 19 | export class AppModule { } 20 | -------------------------------------------------------------------------------- /reactive-forms/src/app/registration.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { RegistrationService } from './registration.service'; 4 | 5 | describe('RegistrationService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [RegistrationService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([RegistrationService], (service: RegistrationService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /reactive-forms/src/app/registration.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | @Injectable({ 4 | providedIn: 'root' 5 | }) 6 | export class RegistrationService { 7 | 8 | _url = 'http://localhost:3000/enroll'; 9 | 10 | constructor(private _http: HttpClient) { } 11 | 12 | register(userData) { 13 | return this._http.post(this._url, userData); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /reactive-forms/src/app/shared/password.validator.ts: -------------------------------------------------------------------------------- 1 | import { AbstractControl } from '@angular/forms'; 2 | 3 | export function PasswordValidator(control: AbstractControl): { [key: string]: boolean } | null { 4 | const password = control.get('password'); 5 | const confirmPassword = control.get('confirmPassword'); 6 | if (password.pristine || confirmPassword.pristine) { 7 | return null; 8 | } 9 | return password && confirmPassword && password.value !== confirmPassword.value ? { 'misMatch': true } : null; 10 | } 11 | -------------------------------------------------------------------------------- /reactive-forms/src/app/shared/user-name.validator.ts: -------------------------------------------------------------------------------- 1 | import { ValidatorFn, AbstractControl } from '@angular/forms'; 2 | 3 | export function ForbiddenNameValidator(forbiddenName: RegExp): ValidatorFn { 4 | return (control: AbstractControl): { [key: string]: any } | null => { 5 | const forbidden = forbiddenName.test(control.value); 6 | return forbidden ? { 'forbiddenName': { value: control.value } } : null; 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /reactive-forms/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/reactive-forms/src/assets/.gitkeep -------------------------------------------------------------------------------- /reactive-forms/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /reactive-forms/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /reactive-forms/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /reactive-forms/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/reactive-forms/src/favicon.ico -------------------------------------------------------------------------------- /reactive-forms/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ReactiveForms 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /reactive-forms/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /reactive-forms/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /reactive-forms/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Web Animations `@angular/platform-browser/animations` 51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 53 | **/ 54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 55 | 56 | /** 57 | * By default, zone.js will patch all possible macroTask and DomEvents 58 | * user can disable parts of macroTask/DomEvents patch by setting following flags 59 | */ 60 | 61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 64 | 65 | /* 66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 68 | */ 69 | // (window as any).__Zone_enable_cross_context_check = true; 70 | 71 | /*************************************************************************************************** 72 | * Zone JS is required by default for Angular itself. 73 | */ 74 | import 'zone.js/dist/zone'; // Included with Angular CLI. 75 | 76 | 77 | 78 | /*************************************************************************************************** 79 | * APPLICATION IMPORTS 80 | */ 81 | -------------------------------------------------------------------------------- /reactive-forms/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /reactive-forms/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /reactive-forms/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "types": [] 7 | }, 8 | "exclude": [ 9 | "src/test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /reactive-forms/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "module": "commonjs", 6 | "types": [ 7 | "jasmine", 8 | "node" 9 | ] 10 | }, 11 | "files": [ 12 | "test.ts", 13 | "polyfills.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /reactive-forms/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /reactive-forms/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2017", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /reactive-forms/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-shadowed-variable": true, 69 | "no-string-literal": false, 70 | "no-string-throw": true, 71 | "no-switch-case-fall-through": true, 72 | "no-trailing-whitespace": true, 73 | "no-unnecessary-initializer": true, 74 | "no-unused-expression": true, 75 | "no-use-before-declare": true, 76 | "no-var-keyword": true, 77 | "object-literal-sort-keys": false, 78 | "one-line": [ 79 | true, 80 | "check-open-brace", 81 | "check-catch", 82 | "check-else", 83 | "check-whitespace" 84 | ], 85 | "prefer-const": true, 86 | "quotemark": [ 87 | true, 88 | "single" 89 | ], 90 | "radix": true, 91 | "semicolon": [ 92 | true, 93 | "always" 94 | ], 95 | "triple-equals": [ 96 | true, 97 | "allow-null-check" 98 | ], 99 | "typedef-whitespace": [ 100 | true, 101 | { 102 | "call-signature": "nospace", 103 | "index-signature": "nospace", 104 | "parameter": "nospace", 105 | "property-declaration": "nospace", 106 | "variable-declaration": "nospace" 107 | } 108 | ], 109 | "unified-signatures": true, 110 | "variable-name": false, 111 | "whitespace": [ 112 | true, 113 | "check-branch", 114 | "check-decl", 115 | "check-operator", 116 | "check-separator", 117 | "check-type" 118 | ], 119 | "no-output-on-prefix": true, 120 | "use-input-property-decorator": true, 121 | "use-output-property-decorator": true, 122 | "use-host-property-decorator": true, 123 | "no-input-rename": true, 124 | "no-output-rename": true, 125 | "use-life-cycle-interface": true, 126 | "use-pipe-transform-interface": true, 127 | "component-class-suffix": true, 128 | "directive-class-suffix": true 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /dist-server 6 | /tmp 7 | /out-tsc 8 | 9 | # dependencies 10 | /node_modules 11 | 12 | # IDEs and editors 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | *.sublime-workspace 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | testem.log 35 | /typings 36 | 37 | # e2e 38 | /e2e/*.js 39 | /e2e/*.map 40 | 41 | # System Files 42 | .DS_Store 43 | Thumbs.db 44 | -------------------------------------------------------------------------------- /server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.5", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", 10 | "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", 11 | "requires": { 12 | "mime-types": "2.1.18", 13 | "negotiator": "0.6.1" 14 | } 15 | }, 16 | "array-flatten": { 17 | "version": "1.1.1", 18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 20 | }, 21 | "body-parser": { 22 | "version": "1.18.3", 23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", 24 | "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", 25 | "requires": { 26 | "bytes": "3.0.0", 27 | "content-type": "1.0.4", 28 | "debug": "2.6.9", 29 | "depd": "1.1.2", 30 | "http-errors": "1.6.3", 31 | "iconv-lite": "0.4.23", 32 | "on-finished": "2.3.0", 33 | "qs": "6.5.2", 34 | "raw-body": "2.3.3", 35 | "type-is": "1.6.16" 36 | } 37 | }, 38 | "bytes": { 39 | "version": "3.0.0", 40 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 41 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 42 | }, 43 | "content-disposition": { 44 | "version": "0.5.2", 45 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 46 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" 47 | }, 48 | "content-type": { 49 | "version": "1.0.4", 50 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 51 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 52 | }, 53 | "cookie": { 54 | "version": "0.3.1", 55 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 56 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 57 | }, 58 | "cookie-signature": { 59 | "version": "1.0.6", 60 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 61 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 62 | }, 63 | "cors": { 64 | "version": "2.8.4", 65 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", 66 | "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=", 67 | "requires": { 68 | "object-assign": "4.1.1", 69 | "vary": "1.1.2" 70 | } 71 | }, 72 | "debug": { 73 | "version": "2.6.9", 74 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 75 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 76 | "requires": { 77 | "ms": "2.0.0" 78 | } 79 | }, 80 | "depd": { 81 | "version": "1.1.2", 82 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 83 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 84 | }, 85 | "destroy": { 86 | "version": "1.0.4", 87 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 88 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 89 | }, 90 | "ee-first": { 91 | "version": "1.1.1", 92 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 93 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 94 | }, 95 | "encodeurl": { 96 | "version": "1.0.2", 97 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 98 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 99 | }, 100 | "escape-html": { 101 | "version": "1.0.3", 102 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 103 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 104 | }, 105 | "etag": { 106 | "version": "1.8.1", 107 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 108 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 109 | }, 110 | "express": { 111 | "version": "4.16.3", 112 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", 113 | "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", 114 | "requires": { 115 | "accepts": "1.3.5", 116 | "array-flatten": "1.1.1", 117 | "body-parser": "1.18.2", 118 | "content-disposition": "0.5.2", 119 | "content-type": "1.0.4", 120 | "cookie": "0.3.1", 121 | "cookie-signature": "1.0.6", 122 | "debug": "2.6.9", 123 | "depd": "1.1.2", 124 | "encodeurl": "1.0.2", 125 | "escape-html": "1.0.3", 126 | "etag": "1.8.1", 127 | "finalhandler": "1.1.1", 128 | "fresh": "0.5.2", 129 | "merge-descriptors": "1.0.1", 130 | "methods": "1.1.2", 131 | "on-finished": "2.3.0", 132 | "parseurl": "1.3.2", 133 | "path-to-regexp": "0.1.7", 134 | "proxy-addr": "2.0.3", 135 | "qs": "6.5.1", 136 | "range-parser": "1.2.0", 137 | "safe-buffer": "5.1.1", 138 | "send": "0.16.2", 139 | "serve-static": "1.13.2", 140 | "setprototypeof": "1.1.0", 141 | "statuses": "1.4.0", 142 | "type-is": "1.6.16", 143 | "utils-merge": "1.0.1", 144 | "vary": "1.1.2" 145 | }, 146 | "dependencies": { 147 | "body-parser": { 148 | "version": "1.18.2", 149 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", 150 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", 151 | "requires": { 152 | "bytes": "3.0.0", 153 | "content-type": "1.0.4", 154 | "debug": "2.6.9", 155 | "depd": "1.1.2", 156 | "http-errors": "1.6.3", 157 | "iconv-lite": "0.4.19", 158 | "on-finished": "2.3.0", 159 | "qs": "6.5.1", 160 | "raw-body": "2.3.2", 161 | "type-is": "1.6.16" 162 | } 163 | }, 164 | "iconv-lite": { 165 | "version": "0.4.19", 166 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 167 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 168 | }, 169 | "qs": { 170 | "version": "6.5.1", 171 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 172 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 173 | }, 174 | "raw-body": { 175 | "version": "2.3.2", 176 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", 177 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", 178 | "requires": { 179 | "bytes": "3.0.0", 180 | "http-errors": "1.6.2", 181 | "iconv-lite": "0.4.19", 182 | "unpipe": "1.0.0" 183 | }, 184 | "dependencies": { 185 | "depd": { 186 | "version": "1.1.1", 187 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", 188 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" 189 | }, 190 | "http-errors": { 191 | "version": "1.6.2", 192 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", 193 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", 194 | "requires": { 195 | "depd": "1.1.1", 196 | "inherits": "2.0.3", 197 | "setprototypeof": "1.0.3", 198 | "statuses": "1.4.0" 199 | } 200 | }, 201 | "setprototypeof": { 202 | "version": "1.0.3", 203 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", 204 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" 205 | } 206 | } 207 | }, 208 | "statuses": { 209 | "version": "1.4.0", 210 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 211 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 212 | } 213 | } 214 | }, 215 | "finalhandler": { 216 | "version": "1.1.1", 217 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", 218 | "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", 219 | "requires": { 220 | "debug": "2.6.9", 221 | "encodeurl": "1.0.2", 222 | "escape-html": "1.0.3", 223 | "on-finished": "2.3.0", 224 | "parseurl": "1.3.2", 225 | "statuses": "1.4.0", 226 | "unpipe": "1.0.0" 227 | }, 228 | "dependencies": { 229 | "statuses": { 230 | "version": "1.4.0", 231 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 232 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 233 | } 234 | } 235 | }, 236 | "forwarded": { 237 | "version": "0.1.2", 238 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 239 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 240 | }, 241 | "fresh": { 242 | "version": "0.5.2", 243 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 244 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 245 | }, 246 | "http-errors": { 247 | "version": "1.6.3", 248 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", 249 | "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", 250 | "requires": { 251 | "depd": "1.1.2", 252 | "inherits": "2.0.3", 253 | "setprototypeof": "1.1.0", 254 | "statuses": "1.5.0" 255 | } 256 | }, 257 | "iconv-lite": { 258 | "version": "0.4.23", 259 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", 260 | "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", 261 | "requires": { 262 | "safer-buffer": "2.1.2" 263 | } 264 | }, 265 | "inherits": { 266 | "version": "2.0.3", 267 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 268 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 269 | }, 270 | "ipaddr.js": { 271 | "version": "1.6.0", 272 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", 273 | "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" 274 | }, 275 | "media-typer": { 276 | "version": "0.3.0", 277 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 278 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 279 | }, 280 | "merge-descriptors": { 281 | "version": "1.0.1", 282 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 283 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 284 | }, 285 | "methods": { 286 | "version": "1.1.2", 287 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 288 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 289 | }, 290 | "mime": { 291 | "version": "1.4.1", 292 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", 293 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" 294 | }, 295 | "mime-db": { 296 | "version": "1.33.0", 297 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", 298 | "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" 299 | }, 300 | "mime-types": { 301 | "version": "2.1.18", 302 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", 303 | "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", 304 | "requires": { 305 | "mime-db": "1.33.0" 306 | } 307 | }, 308 | "ms": { 309 | "version": "2.0.0", 310 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 311 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 312 | }, 313 | "negotiator": { 314 | "version": "0.6.1", 315 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 316 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 317 | }, 318 | "object-assign": { 319 | "version": "4.1.1", 320 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 321 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 322 | }, 323 | "on-finished": { 324 | "version": "2.3.0", 325 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 326 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 327 | "requires": { 328 | "ee-first": "1.1.1" 329 | } 330 | }, 331 | "parseurl": { 332 | "version": "1.3.2", 333 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", 334 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" 335 | }, 336 | "path-to-regexp": { 337 | "version": "0.1.7", 338 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 339 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 340 | }, 341 | "proxy-addr": { 342 | "version": "2.0.3", 343 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", 344 | "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", 345 | "requires": { 346 | "forwarded": "0.1.2", 347 | "ipaddr.js": "1.6.0" 348 | } 349 | }, 350 | "qs": { 351 | "version": "6.5.2", 352 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 353 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" 354 | }, 355 | "range-parser": { 356 | "version": "1.2.0", 357 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", 358 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" 359 | }, 360 | "raw-body": { 361 | "version": "2.3.3", 362 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", 363 | "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", 364 | "requires": { 365 | "bytes": "3.0.0", 366 | "http-errors": "1.6.3", 367 | "iconv-lite": "0.4.23", 368 | "unpipe": "1.0.0" 369 | } 370 | }, 371 | "safe-buffer": { 372 | "version": "5.1.1", 373 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 374 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 375 | }, 376 | "safer-buffer": { 377 | "version": "2.1.2", 378 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 379 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 380 | }, 381 | "send": { 382 | "version": "0.16.2", 383 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", 384 | "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", 385 | "requires": { 386 | "debug": "2.6.9", 387 | "depd": "1.1.2", 388 | "destroy": "1.0.4", 389 | "encodeurl": "1.0.2", 390 | "escape-html": "1.0.3", 391 | "etag": "1.8.1", 392 | "fresh": "0.5.2", 393 | "http-errors": "1.6.3", 394 | "mime": "1.4.1", 395 | "ms": "2.0.0", 396 | "on-finished": "2.3.0", 397 | "range-parser": "1.2.0", 398 | "statuses": "1.4.0" 399 | }, 400 | "dependencies": { 401 | "statuses": { 402 | "version": "1.4.0", 403 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 404 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 405 | } 406 | } 407 | }, 408 | "serve-static": { 409 | "version": "1.13.2", 410 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", 411 | "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", 412 | "requires": { 413 | "encodeurl": "1.0.2", 414 | "escape-html": "1.0.3", 415 | "parseurl": "1.3.2", 416 | "send": "0.16.2" 417 | } 418 | }, 419 | "setprototypeof": { 420 | "version": "1.1.0", 421 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", 422 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" 423 | }, 424 | "statuses": { 425 | "version": "1.5.0", 426 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 427 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 428 | }, 429 | "type-is": { 430 | "version": "1.6.16", 431 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", 432 | "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", 433 | "requires": { 434 | "media-typer": "0.3.0", 435 | "mime-types": "2.1.18" 436 | } 437 | }, 438 | "unpipe": { 439 | "version": "1.0.0", 440 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 441 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 442 | }, 443 | "utils-merge": { 444 | "version": "1.0.1", 445 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 446 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 447 | }, 448 | "vary": { 449 | "version": "1.1.2", 450 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 451 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 452 | } 453 | } 454 | } 455 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "body-parser": "^1.18.3", 15 | "cors": "^2.8.4", 16 | "express": "^4.16.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require('body-parser'); 3 | const cors = require('cors') 4 | 5 | const PORT = 3000; 6 | const app = express(); 7 | app.use(bodyParser.json()); 8 | app.use(cors()) 9 | 10 | app.get('/', function(req, res) { 11 | res.send('Hello from server') 12 | }) 13 | 14 | app.post('/enroll', function(req, res) { 15 | console.log(req.body) 16 | res.status(200).send({"message": "Data received"}); 17 | }) 18 | 19 | app.listen(PORT, function(){ 20 | console.log("Server running on localhost:" + PORT); 21 | }); -------------------------------------------------------------------------------- /template-driven-forms/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /template-driven-forms/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /template-driven-forms/README.md: -------------------------------------------------------------------------------- 1 | # TemplateDrivenForms 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /template-driven-forms/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "template-driven-forms": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/template-driven-forms", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "fileReplacements": [ 33 | { 34 | "replace": "src/environments/environment.ts", 35 | "with": "src/environments/environment.prod.ts" 36 | } 37 | ], 38 | "optimization": true, 39 | "outputHashing": "all", 40 | "sourceMap": false, 41 | "extractCss": true, 42 | "namedChunks": false, 43 | "aot": true, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true 47 | } 48 | } 49 | }, 50 | "serve": { 51 | "builder": "@angular-devkit/build-angular:dev-server", 52 | "options": { 53 | "browserTarget": "template-driven-forms:build" 54 | }, 55 | "configurations": { 56 | "production": { 57 | "browserTarget": "template-driven-forms:build:production" 58 | } 59 | } 60 | }, 61 | "extract-i18n": { 62 | "builder": "@angular-devkit/build-angular:extract-i18n", 63 | "options": { 64 | "browserTarget": "template-driven-forms:build" 65 | } 66 | }, 67 | "test": { 68 | "builder": "@angular-devkit/build-angular:karma", 69 | "options": { 70 | "main": "src/test.ts", 71 | "polyfills": "src/polyfills.ts", 72 | "tsConfig": "src/tsconfig.spec.json", 73 | "karmaConfig": "src/karma.conf.js", 74 | "styles": [ 75 | "styles.css" 76 | ], 77 | "scripts": [], 78 | "assets": [ 79 | "src/favicon.ico", 80 | "src/assets" 81 | ] 82 | } 83 | }, 84 | "lint": { 85 | "builder": "@angular-devkit/build-angular:tslint", 86 | "options": { 87 | "tsConfig": [ 88 | "src/tsconfig.app.json", 89 | "src/tsconfig.spec.json" 90 | ], 91 | "exclude": [ 92 | "**/node_modules/**" 93 | ] 94 | } 95 | } 96 | } 97 | }, 98 | "template-driven-forms-e2e": { 99 | "root": "e2e/", 100 | "projectType": "application", 101 | "architect": { 102 | "e2e": { 103 | "builder": "@angular-devkit/build-angular:protractor", 104 | "options": { 105 | "protractorConfig": "e2e/protractor.conf.js", 106 | "devServerTarget": "template-driven-forms:serve" 107 | } 108 | }, 109 | "lint": { 110 | "builder": "@angular-devkit/build-angular:tslint", 111 | "options": { 112 | "tsConfig": "e2e/tsconfig.e2e.json", 113 | "exclude": [ 114 | "**/node_modules/**" 115 | ] 116 | } 117 | } 118 | } 119 | } 120 | }, 121 | "defaultProject": "template-driven-forms" 122 | } -------------------------------------------------------------------------------- /template-driven-forms/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /template-driven-forms/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /template-driven-forms/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /template-driven-forms/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /template-driven-forms/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "template-driven-forms", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "^6.0.0", 15 | "@angular/common": "^6.0.0", 16 | "@angular/compiler": "^6.0.0", 17 | "@angular/core": "^6.0.0", 18 | "@angular/forms": "^6.0.0", 19 | "@angular/http": "^6.0.0", 20 | "@angular/platform-browser": "^6.0.0", 21 | "@angular/platform-browser-dynamic": "^6.0.0", 22 | "@angular/router": "^6.0.0", 23 | "core-js": "^2.5.4", 24 | "rxjs": "^6.0.0", 25 | "zone.js": "^0.8.26" 26 | }, 27 | "devDependencies": { 28 | "@angular/compiler-cli": "^6.0.0", 29 | "@angular-devkit/build-angular": "~0.6.0", 30 | "typescript": "~2.7.2", 31 | "@angular/cli": "~6.0.0", 32 | "@angular/language-service": "^6.0.0", 33 | "@types/jasmine": "~2.8.6", 34 | "@types/jasminewd2": "~2.0.3", 35 | "@types/node": "~8.9.4", 36 | "codelyzer": "~4.2.1", 37 | "jasmine-core": "~2.99.1", 38 | "jasmine-spec-reporter": "~4.2.1", 39 | "karma": "~1.7.1", 40 | "karma-chrome-launcher": "~2.2.0", 41 | "karma-coverage-istanbul-reporter": "~1.4.2", 42 | "karma-jasmine": "~1.1.1", 43 | "karma-jasmine-html-reporter": "^0.2.2", 44 | "protractor": "~5.3.0", 45 | "ts-node": "~5.0.1", 46 | "tslint": "~5.9.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/template-driven-forms/src/app/app.component.css -------------------------------------------------------------------------------- /template-driven-forms/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Bootcamp Enrollment Form

3 | 4 |
5 | 6 |
7 | 8 | 9 | Name is required 10 |
11 | 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 | Phone number is required 23 | Phone number must be 10 digits 24 |
25 |
26 | 27 |
28 | 32 | Please choose a topic 33 |
34 | 35 |
36 | 37 |
38 | 39 | 40 |
41 |
42 | 43 | 44 |
45 |
46 | 47 |
48 | 49 | 52 |
53 | 54 | 55 | 56 |
57 |
58 | {{errorMsg}} 59 |
60 |
-------------------------------------------------------------------------------- /template-driven-forms/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { User } from './user'; 3 | import { EnrollmentService } from './enrollment.service'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | templateUrl: './app.component.html', 8 | styleUrls: ['./app.component.css'] 9 | }) 10 | export class AppComponent { 11 | title = 'app'; 12 | topics = ['Angular', 'React', 'Vue']; 13 | userModel = new User('Rob', 'rob@test.com', 5556665566, 'default', 'morning', true); 14 | topicHasError = true; 15 | submitted = false; 16 | errorMsg = ''; 17 | 18 | constructor(private _enrollmentService: EnrollmentService) {} 19 | 20 | validateTopic(value) { 21 | if (value === 'default') { 22 | this.topicHasError = true; 23 | } else { 24 | this.topicHasError = false; 25 | } 26 | } 27 | 28 | onSubmit() { 29 | this.submitted = true; 30 | this._enrollmentService.enroll(this.userModel) 31 | .subscribe( 32 | response => console.log('Success!', response), 33 | error => this.errorMsg = error.statusText 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http'; 5 | import { AppComponent } from './app.component'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | BrowserModule, 13 | FormsModule, 14 | HttpClientModule 15 | ], 16 | providers: [], 17 | bootstrap: [AppComponent] 18 | }) 19 | export class AppModule { } 20 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/enrollment.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { EnrollmentService } from './enrollment.service'; 4 | 5 | describe('EnrollmentService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [EnrollmentService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([EnrollmentService], (service: EnrollmentService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/enrollment.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient, HttpErrorResponse } from '@angular/common/http'; 3 | import { User } from './user'; 4 | import { catchError } from 'rxjs/operators'; 5 | import { throwError } from 'rxjs'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class EnrollmentService { 11 | 12 | _url = 'http://localhost:3000/enroll'; 13 | constructor(private _http: HttpClient) { } 14 | 15 | enroll (user: User) { 16 | return this._http.post(this._url, user) 17 | .pipe(catchError(this.errorHandler)) 18 | } 19 | 20 | errorHandler(error: HttpErrorResponse) { 21 | return throwError(error) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /template-driven-forms/src/app/user.ts: -------------------------------------------------------------------------------- 1 | export class User { 2 | constructor( 3 | public name: string, 4 | public email: string, 5 | public phone: number, 6 | public topic: string, 7 | public timePreference: string, 8 | public subscribe: boolean 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /template-driven-forms/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/template-driven-forms/src/assets/.gitkeep -------------------------------------------------------------------------------- /template-driven-forms/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /template-driven-forms/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /template-driven-forms/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /template-driven-forms/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gopinav/Angular-Forms-Tutorial/92a6552ce1b5894dfe122db07c1bc16dfb8bfaa6/template-driven-forms/src/favicon.ico -------------------------------------------------------------------------------- /template-driven-forms/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Template Driven Forms 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /template-driven-forms/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /template-driven-forms/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /template-driven-forms/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Web Animations `@angular/platform-browser/animations` 51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 53 | **/ 54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 55 | 56 | /** 57 | * By default, zone.js will patch all possible macroTask and DomEvents 58 | * user can disable parts of macroTask/DomEvents patch by setting following flags 59 | */ 60 | 61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 64 | 65 | /* 66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 68 | */ 69 | // (window as any).__Zone_enable_cross_context_check = true; 70 | 71 | /*************************************************************************************************** 72 | * Zone JS is required by default for Angular itself. 73 | */ 74 | import 'zone.js/dist/zone'; // Included with Angular CLI. 75 | 76 | 77 | 78 | /*************************************************************************************************** 79 | * APPLICATION IMPORTS 80 | */ 81 | -------------------------------------------------------------------------------- /template-driven-forms/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /template-driven-forms/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /template-driven-forms/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "types": [] 7 | }, 8 | "exclude": [ 9 | "src/test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /template-driven-forms/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "module": "commonjs", 6 | "types": [ 7 | "jasmine", 8 | "node" 9 | ] 10 | }, 11 | "files": [ 12 | "test.ts", 13 | "polyfills.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /template-driven-forms/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /template-driven-forms/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2017", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /template-driven-forms/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-shadowed-variable": true, 69 | "no-string-literal": false, 70 | "no-string-throw": true, 71 | "no-switch-case-fall-through": true, 72 | "no-trailing-whitespace": true, 73 | "no-unnecessary-initializer": true, 74 | "no-unused-expression": true, 75 | "no-use-before-declare": true, 76 | "no-var-keyword": true, 77 | "object-literal-sort-keys": false, 78 | "one-line": [ 79 | true, 80 | "check-open-brace", 81 | "check-catch", 82 | "check-else", 83 | "check-whitespace" 84 | ], 85 | "prefer-const": true, 86 | "quotemark": [ 87 | true, 88 | "single" 89 | ], 90 | "radix": true, 91 | "semicolon": [ 92 | true, 93 | "always" 94 | ], 95 | "triple-equals": [ 96 | true, 97 | "allow-null-check" 98 | ], 99 | "typedef-whitespace": [ 100 | true, 101 | { 102 | "call-signature": "nospace", 103 | "index-signature": "nospace", 104 | "parameter": "nospace", 105 | "property-declaration": "nospace", 106 | "variable-declaration": "nospace" 107 | } 108 | ], 109 | "unified-signatures": true, 110 | "variable-name": false, 111 | "whitespace": [ 112 | true, 113 | "check-branch", 114 | "check-decl", 115 | "check-operator", 116 | "check-separator", 117 | "check-type" 118 | ], 119 | "no-output-on-prefix": true, 120 | "use-input-property-decorator": true, 121 | "use-output-property-decorator": true, 122 | "use-host-property-decorator": true, 123 | "no-input-rename": true, 124 | "no-output-rename": true, 125 | "use-life-cycle-interface": true, 126 | "use-pipe-transform-interface": true, 127 | "component-class-suffix": true, 128 | "directive-class-suffix": true 129 | } 130 | } 131 | --------------------------------------------------------------------------------