├── src ├── app │ ├── shared │ │ └── index.ts │ ├── app.component.css │ ├── forms │ │ ├── forms.component.css │ │ ├── forms.component.spec.ts │ │ ├── forms.component.ts │ │ └── forms.component.html │ ├── reactive-forms │ │ ├── reactive-forms.component.css │ │ ├── reactive-forms.component.spec.ts │ │ ├── reactive-forms.component.html │ │ └── reactive-forms.component.ts │ ├── index.ts │ ├── app.component.html │ ├── switch-control │ │ ├── switch-control.component.css │ │ ├── switch-control.component.html │ │ ├── switch-control.component.spec.ts │ │ └── switch-control.component.ts │ ├── app.component.ts │ ├── app.module.ts │ └── app.component.spec.ts ├── assets │ ├── .gitkeep │ └── .npmignore ├── favicon.ico ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── typings.d.ts ├── index.html ├── main.ts ├── tsconfig.json ├── polyfills.ts ├── test.ts └── styles.css ├── README.md ├── e2e ├── app.po.ts ├── app.e2e-spec.ts └── tsconfig.json ├── .editorconfig ├── .gitignore ├── protractor.conf.js ├── angular-cli.json ├── LICENSE ├── karma.conf.js ├── package.json └── tslint.json /src/app/shared/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/.npmignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/forms/forms.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/reactive-forms/reactive-forms.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kara/ac-forms/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/app/index.ts: -------------------------------------------------------------------------------- 1 | export * from './app.component'; 2 | export * from './app.module'; 3 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the repo for the live demo of Angular forms at Angular Connect 2016. 2 | 3 | It's not accepting PRs or issues at this time. Thanks! -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | -------------------------------------------------------------------------------- /src/app/switch-control/switch-control.component.css: -------------------------------------------------------------------------------- 1 | :host { 2 | display: block; 3 | } 4 | 5 | .selected { 6 | background: black; 7 | color: white; 8 | } -------------------------------------------------------------------------------- /src/app/switch-control/switch-control.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | // Typings reference file, see links for more information 2 | // https://github.com/typings/typings 3 | // https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html 4 | 5 | declare var System: any; 6 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, element, by } from 'protractor/globals'; 2 | 3 | export class AcFormsPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.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 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | max_line_length = 0 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators } from '@angular/forms'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'] 8 | }) 9 | export class AppComponent { 10 | } 11 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AcForms 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Loading... 14 | 15 | 16 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AcFormsPage } from './app.po'; 2 | 3 | describe('ac-forms App', function() { 4 | let page: AcFormsPage; 5 | 6 | beforeEach(() => { 7 | page = new AcFormsPage(); 8 | }); 9 | 10 | it('should display message saying app works', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('app works!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /src/app/forms/forms.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | 3 | import { TestBed, async } from '@angular/core/testing'; 4 | import { FormsComponent } from './forms.component'; 5 | 6 | describe('Component: Forms', () => { 7 | it('should create an instance', () => { 8 | let component = new FormsComponent(); 9 | expect(component).toBeTruthy(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import './polyfills.ts'; 2 | 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | import { enableProdMode } from '@angular/core'; 5 | import { environment } from './environments/environment'; 6 | import { AppModule } from './app/'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppModule); 13 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "module": "commonjs", 8 | "moduleResolution": "node", 9 | "outDir": "../dist/out-tsc-e2e", 10 | "sourceMap": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "../node_modules/@types" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/app/reactive-forms/reactive-forms.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | 3 | import { TestBed, async } from '@angular/core/testing'; 4 | import { ReactiveFormsComponent } from './reactive-forms.component'; 5 | 6 | describe('Component: ReactiveForms', () => { 7 | it('should create an instance', () => { 8 | let component = new ReactiveFormsComponent(); 9 | expect(component).toBeTruthy(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/app/switch-control/switch-control.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | 3 | import { TestBed, async } from '@angular/core/testing'; 4 | import { SwitchControlComponent } from './switch-control.component'; 5 | 6 | describe('Component: SwitchControl', () => { 7 | it('should create an instance', () => { 8 | let component = new SwitchControlComponent(); 9 | expect(component).toBeTruthy(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": false, 4 | "emitDecoratorMetadata": true, 5 | "experimentalDecorators": true, 6 | "lib": ["es6", "dom"], 7 | "mapRoot": "./", 8 | "module": "es6", 9 | "moduleResolution": "node", 10 | "outDir": "../dist/out-tsc", 11 | "sourceMap": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "../node_modules/@types" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | *.launch 16 | .settings/ 17 | 18 | # misc 19 | /.sass-cache 20 | /connect.lock 21 | /coverage/* 22 | /libpeerconnection.log 23 | npm-debug.log 24 | testem.log 25 | /typings 26 | 27 | # e2e 28 | /e2e/*.js 29 | /e2e/*.map 30 | 31 | #System Files 32 | .DS_Store 33 | Thumbs.db 34 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | // This file includes polyfills needed by Angular 2 and is loaded before 2 | // the app. You can add your own extra polyfills to this file. 3 | import 'core-js/es6/symbol'; 4 | import 'core-js/es6/object'; 5 | import 'core-js/es6/function'; 6 | import 'core-js/es6/parse-int'; 7 | import 'core-js/es6/parse-float'; 8 | import 'core-js/es6/number'; 9 | import 'core-js/es6/math'; 10 | import 'core-js/es6/string'; 11 | import 'core-js/es6/date'; 12 | import 'core-js/es6/array'; 13 | import 'core-js/es6/regexp'; 14 | import 'core-js/es6/map'; 15 | import 'core-js/es6/set'; 16 | import 'core-js/es6/reflect'; 17 | 18 | import 'core-js/es7/reflect'; 19 | import 'zone.js/dist/zone'; 20 | -------------------------------------------------------------------------------- /src/app/forms/forms.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Directive } from '@angular/core'; 2 | import { AbstractControl, NG_VALIDATORS } from '@angular/forms'; 3 | 4 | function passwordMatcher(c: AbstractControl) { 5 | if (!c.get('password') || !c.get('confirm')) return null; 6 | return c.get('password').value === c.get('confirm').value 7 | ? null : {'nomatch': true}; 8 | } 9 | 10 | @Directive({ 11 | selector: '[password-matcher]', 12 | providers: [ 13 | {provide: NG_VALIDATORS, multi: true, useValue: passwordMatcher} 14 | ] 15 | }) 16 | export class PasswordMatcher { 17 | 18 | } 19 | 20 | @Component({ 21 | selector: 'forms-comp', 22 | templateUrl: './forms.component.html', 23 | styleUrls: ['./forms.component.css'] 24 | }) 25 | export class FormsComponent { 26 | name = {first: 'Nancy', last: 'Drew'}; 27 | } 28 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/docs/referenceConf.js 3 | 4 | /*global jasmine */ 5 | var SpecReporter = require('jasmine-spec-reporter'); 6 | 7 | exports.config = { 8 | allScriptsTimeout: 11000, 9 | specs: [ 10 | './e2e/**/*.e2e-spec.ts' 11 | ], 12 | capabilities: { 13 | 'browserName': 'chrome' 14 | }, 15 | directConnect: true, 16 | baseUrl: 'http://localhost:4200/', 17 | framework: 'jasmine', 18 | jasmineNodeOpts: { 19 | showColors: true, 20 | defaultTimeoutInterval: 30000, 21 | print: function() {} 22 | }, 23 | useAllAngular2AppRoots: true, 24 | beforeLaunch: function() { 25 | require('ts-node').register({ 26 | project: 'e2e' 27 | }); 28 | }, 29 | onPrepare: function() { 30 | jasmine.getEnv().addReporter(new SpecReporter()); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /src/app/switch-control/switch-control.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators} from '@angular/forms'; 3 | 4 | @Component({ 5 | selector: 'switch-control', 6 | templateUrl: './switch-control.component.html', 7 | styleUrls: ['./switch-control.component.css'], 8 | providers: [ 9 | {provide: NG_VALUE_ACCESSOR, multi: true, useExisting: SwitchControlComponent} 10 | ] 11 | }) 12 | export class SwitchControlComponent implements ControlValueAccessor { 13 | isOn: boolean; 14 | _onChange: (value: any) => void; 15 | 16 | writeValue(value: any) { 17 | this.isOn = !!value; 18 | } 19 | 20 | registerOnChange(fn: (value: any) => void) { 21 | this._onChange = fn; 22 | } 23 | 24 | registerOnTouched() {} 25 | 26 | toggle(isOn: boolean) { 27 | this.isOn = isOn; 28 | this._onChange(isOn); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 4 | import { HttpModule } from '@angular/http'; 5 | import { MaterialModule } from '@angular/material'; 6 | import { AppComponent } from './app.component'; 7 | import { FormsComponent, PasswordMatcher } from './forms/forms.component'; 8 | import { ReactiveFormsComponent } from './reactive-forms/reactive-forms.component'; 9 | import { SwitchControlComponent } from './switch-control/switch-control.component'; 10 | 11 | @NgModule({ 12 | declarations: [ 13 | AppComponent, 14 | FormsComponent, 15 | ReactiveFormsComponent, 16 | SwitchControlComponent, 17 | PasswordMatcher 18 | ], 19 | imports: [ 20 | BrowserModule, 21 | FormsModule, 22 | ReactiveFormsModule, 23 | HttpModule, 24 | MaterialModule.forRoot() 25 | ], 26 | providers: [], 27 | bootstrap: [AppComponent] 28 | }) 29 | export class AppModule { } 30 | -------------------------------------------------------------------------------- /angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "project": { 3 | "version": "1.0.0-beta.15", 4 | "name": "ac-forms" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": "assets", 11 | "index": "index.html", 12 | "main": "main.ts", 13 | "test": "test.ts", 14 | "tsconfig": "tsconfig.json", 15 | "prefix": "app", 16 | "mobile": false, 17 | "styles": [ 18 | "styles.css" 19 | ], 20 | "scripts": [], 21 | "environments": { 22 | "source": "environments/environment.ts", 23 | "dev": "environments/environment.ts", 24 | "prod": "environments/environment.prod.ts" 25 | } 26 | } 27 | ], 28 | "addons": [], 29 | "packages": [], 30 | "e2e": { 31 | "protractor": { 32 | "config": "./protractor.conf.js" 33 | } 34 | }, 35 | "test": { 36 | "karma": { 37 | "config": "./karma.conf.js" 38 | } 39 | }, 40 | "defaults": { 41 | "styleExt": "css", 42 | "prefixInterfaces": false 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/app/reactive-forms/reactive-forms.component.html: -------------------------------------------------------------------------------- 1 |

ReactiveFormsModule

2 | 3 | 4 | Registration form 5 | 6 |
7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 | 23 |

Form: {{ form.value | json }}

24 |

Form status: {{ form.status }}

25 |

Account status: {{ form.get('account').errors | json }}

26 |
27 | -------------------------------------------------------------------------------- /src/app/reactive-forms/reactive-forms.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; 3 | 4 | function passwordMatcher(c: AbstractControl) { 5 | return c.get('password').value === c.get('confirm').value 6 | ? null : {'nomatch': true}; 7 | } 8 | 9 | @Component({ 10 | selector: 'reactive-forms-comp', 11 | templateUrl: './reactive-forms.component.html', 12 | styleUrls: ['./reactive-forms.component.css'] 13 | }) 14 | export class ReactiveFormsComponent { 15 | form: FormGroup; 16 | 17 | constructor(public fb: FormBuilder) { 18 | this.form = this.fb.group({ 19 | first: '', 20 | last: '', 21 | account: this.fb.group({ 22 | username: '', 23 | password: ['', Validators.required], 24 | confirm: ['', Validators.required], 25 | }, {validator: passwordMatcher}), 26 | newsletter: '' 27 | }); 28 | this.form.patchValue({ 29 | first: 'Nancy', 30 | last: 'Drew' 31 | }); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Kara 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/0.13/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', 'angular-cli'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-remap-istanbul'), 12 | require('angular-cli/plugins/karma') 13 | ], 14 | files: [ 15 | { pattern: './src/test.ts', watched: false } 16 | ], 17 | preprocessors: { 18 | './src/test.ts': ['angular-cli'] 19 | }, 20 | remapIstanbulReporter: { 21 | reports: { 22 | html: 'coverage', 23 | lcovonly: './coverage/coverage.lcov' 24 | } 25 | }, 26 | angularCli: { 27 | config: './angular-cli.json', 28 | environment: 'dev' 29 | }, 30 | reporters: ['progress', 'karma-remap-istanbul'], 31 | port: 9876, 32 | colors: true, 33 | logLevel: config.LOG_INFO, 34 | autoWatch: true, 35 | browsers: ['Chrome'], 36 | singleRun: false 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /src/app/forms/forms.component.html: -------------------------------------------------------------------------------- 1 |

FormsModule

2 | 3 | 4 | Registration form 5 | 6 |
7 | 8 | 9 |
10 | 11 | 12 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 | 24 |

Form: {{ f.value | json }}

25 |

Form status: {{ f.control.status }}

26 |

Account errors: {{ account.control?.errors | json }}

27 |
28 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | 3 | import { TestBed, async } from '@angular/core/testing'; 4 | import { AppComponent } from './app.component'; 5 | 6 | describe('App: AcForms', () => { 7 | beforeEach(() => { 8 | TestBed.configureTestingModule({ 9 | declarations: [ 10 | AppComponent 11 | ], 12 | }); 13 | }); 14 | 15 | it('should create the app', async(() => { 16 | let fixture = TestBed.createComponent(AppComponent); 17 | let app = fixture.debugElement.componentInstance; 18 | expect(app).toBeTruthy(); 19 | })); 20 | 21 | it(`should have as title 'app works!'`, async(() => { 22 | let fixture = TestBed.createComponent(AppComponent); 23 | let app = fixture.debugElement.componentInstance; 24 | expect(app.title).toEqual('app works!'); 25 | })); 26 | 27 | it('should render title in a h1 tag', async(() => { 28 | let fixture = TestBed.createComponent(AppComponent); 29 | fixture.detectChanges(); 30 | let compiled = fixture.debugElement.nativeElement; 31 | expect(compiled.querySelector('h1').textContent).toContain('app works!'); 32 | })); 33 | }); 34 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | import './polyfills.ts'; 2 | 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | 10 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 11 | declare var __karma__: any; 12 | declare var require: any; 13 | 14 | // Prevent Karma from running prematurely. 15 | __karma__.loaded = function () {}; 16 | 17 | 18 | Promise.all([ 19 | System.import('@angular/core/testing'), 20 | System.import('@angular/platform-browser-dynamic/testing') 21 | ]) 22 | // First, initialize the Angular testing environment. 23 | .then(([testing, testingBrowser]) => { 24 | testing.getTestBed().initTestEnvironment( 25 | testingBrowser.BrowserDynamicTestingModule, 26 | testingBrowser.platformBrowserDynamicTesting() 27 | ); 28 | }) 29 | // Then we find all the tests. 30 | .then(() => require.context('./', true, /\.spec\.ts/)) 31 | // And load the modules. 32 | .then(context => context.keys().map(context)) 33 | // Finally, start Karma to run the tests. 34 | .then(__karma__.start, __karma__.error); 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ac-forms", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "angular-cli": {}, 6 | "scripts": { 7 | "start": "ng serve", 8 | "lint": "tslint \"src/**/*.ts\"", 9 | "test": "ng test", 10 | "pree2e": "webdriver-manager update", 11 | "e2e": "protractor" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/common": "2.0.0", 16 | "@angular/compiler": "2.0.0", 17 | "@angular/core": "2.0.0", 18 | "@angular/forms": "2.0.0", 19 | "@angular/http": "2.0.0", 20 | "@angular/material": "^2.0.0-alpha.9-experimental", 21 | "@angular/platform-browser": "2.0.0", 22 | "@angular/platform-browser-dynamic": "2.0.0", 23 | "@angular/router": "3.0.0", 24 | "core-js": "^2.4.1", 25 | "rxjs": "5.0.0-beta.12", 26 | "ts-helpers": "^1.1.1", 27 | "zone.js": "^0.6.23" 28 | }, 29 | "devDependencies": { 30 | "@types/jasmine": "^2.2.30", 31 | "angular-cli": "1.0.0-beta.15", 32 | "codelyzer": "~0.0.26", 33 | "jasmine-core": "2.4.1", 34 | "jasmine-spec-reporter": "2.5.0", 35 | "karma": "1.2.0", 36 | "karma-chrome-launcher": "^2.0.0", 37 | "karma-cli": "^1.0.1", 38 | "karma-jasmine": "^1.0.2", 39 | "karma-remap-istanbul": "^0.2.1", 40 | "protractor": "4.0.5", 41 | "ts-node": "1.2.1", 42 | "tslint": "3.13.0", 43 | "typescript": "2.0.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | @import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css'; 4 | 5 | /*here start the horrible, hack-y styles. for demo use only! */ 6 | 7 | body { 8 | background: rgba(0,0,0,0.04); 9 | font-family: Roboto, sans-serif; 10 | } 11 | 12 | * { 13 | -webkit-font-smoothing: antialiased; 14 | -moz-osx-font-smoothing: grayscale; 15 | } 16 | 17 | input.ng-invalid.ng-touched { 18 | border-bottom: 1px solid red; 19 | } 20 | 21 | .app-wrapper { 22 | display: flex; 23 | justify-content: space-around; 24 | } 25 | 26 | reactive-forms-comp, forms-comp { 27 | display: flex; 28 | flex-direction: column; 29 | align-items: center; 30 | } 31 | 32 | md-card { 33 | width: 500px; 34 | margin: 8px; 35 | } 36 | 37 | input { 38 | width: 100%; 39 | box-sizing: border-box; 40 | height: 36px; 41 | margin: 8px 0; 42 | font-size: 100%; 43 | border: none; 44 | border-bottom: 1px solid rgba(0,0,0,0.18); 45 | font: inherit; 46 | outline: none; 47 | } 48 | 49 | input[type="radio"] { 50 | height: auto; 51 | width: auto; 52 | margin: 6px; 53 | } 54 | 55 | label { 56 | display: block; 57 | margin: 16px 0; 58 | font-style: italic; 59 | } 60 | 61 | .errors { 62 | color: red; 63 | } 64 | 65 | [md-button] { 66 | margin: 0 -6px !important; 67 | } 68 | 69 | form md-card-actions { 70 | margin-bottom: -24px; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "class-name": true, 7 | "comment-format": [ 8 | true, 9 | "check-space" 10 | ], 11 | "curly": true, 12 | "eofline": true, 13 | "forin": true, 14 | "indent": [ 15 | true, 16 | "spaces" 17 | ], 18 | "label-position": true, 19 | "label-undefined": true, 20 | "max-line-length": [ 21 | true, 22 | 140 23 | ], 24 | "member-access": false, 25 | "member-ordering": [ 26 | true, 27 | "static-before-instance", 28 | "variables-before-functions" 29 | ], 30 | "no-arg": true, 31 | "no-bitwise": true, 32 | "no-console": [ 33 | true, 34 | "debug", 35 | "info", 36 | "time", 37 | "timeEnd", 38 | "trace" 39 | ], 40 | "no-construct": true, 41 | "no-debugger": true, 42 | "no-duplicate-key": true, 43 | "no-duplicate-variable": true, 44 | "no-empty": false, 45 | "no-eval": true, 46 | "no-inferrable-types": true, 47 | "no-shadowed-variable": true, 48 | "no-string-literal": false, 49 | "no-switch-case-fall-through": true, 50 | "no-trailing-whitespace": true, 51 | "no-unused-expression": true, 52 | "no-unused-variable": true, 53 | "no-unreachable": true, 54 | "no-use-before-declare": true, 55 | "no-var-keyword": true, 56 | "object-literal-sort-keys": false, 57 | "one-line": [ 58 | true, 59 | "check-open-brace", 60 | "check-catch", 61 | "check-else", 62 | "check-whitespace" 63 | ], 64 | "quotemark": [ 65 | true, 66 | "single" 67 | ], 68 | "radix": true, 69 | "semicolon": [ 70 | "always" 71 | ], 72 | "triple-equals": [ 73 | true, 74 | "allow-null-check" 75 | ], 76 | "typedef-whitespace": [ 77 | true, 78 | { 79 | "call-signature": "nospace", 80 | "index-signature": "nospace", 81 | "parameter": "nospace", 82 | "property-declaration": "nospace", 83 | "variable-declaration": "nospace" 84 | } 85 | ], 86 | "variable-name": false, 87 | "whitespace": [ 88 | true, 89 | "check-branch", 90 | "check-decl", 91 | "check-operator", 92 | "check-separator", 93 | "check-type" 94 | ], 95 | 96 | "directive-selector-prefix": [true, "app"], 97 | "component-selector-prefix": [true, "app"], 98 | "directive-selector-name": [true, "camelCase"], 99 | "component-selector-name": [true, "kebab-case"], 100 | "directive-selector-type": [true, "attribute"], 101 | "component-selector-type": [true, "element"], 102 | "use-input-property-decorator": true, 103 | "use-output-property-decorator": true, 104 | "use-host-property-decorator": true, 105 | "no-input-rename": true, 106 | "no-output-rename": true, 107 | "use-life-cycle-interface": true, 108 | "use-pipe-transform-interface": true, 109 | "component-class-suffix": true, 110 | "directive-class-suffix": true 111 | } 112 | } 113 | --------------------------------------------------------------------------------