Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions angular-cli.json → .angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"version": "1.0.0-beta.20-4",
"name": "form-example"
"name": "forms-example"
},
"apps": [
{
Expand All @@ -13,47 +13,45 @@
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
"component": {}
}
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
max_line_length = off
trim_trailing_whitespace = false
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@
# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea
/.vscode
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
Expand All @@ -30,6 +37,6 @@ testem.log
/e2e/*.js
/e2e/*.map

#System Files
# System Files
.DS_Store
Thumbs.db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FormExample

This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.20-4.
This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.2.0.

## Development server
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.
Expand Down
12 changes: 6 additions & 6 deletions e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {FormExamplePage} from './app.po';
import { FormsExamplePage } from './app.po';

describe('form-example App', function() {
let page: FormExamplePage;
describe('forms-example App', () => {
let page: FormsExamplePage;

beforeEach(() => {
page = new FormExamplePage();
page = new FormsExamplePage();
});

it('should display message saying app works', () => {
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
expect(page.getParagraphText()).toEqual('My form!');
});
});
4 changes: 2 additions & 2 deletions e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {browser, element, by} from 'protractor';
import { browser, by, element } from 'protractor';

export class FormExamplePage {
export class FormsExamplePage {
navigateTo() {
return browser.get('/');
}
Expand Down
13 changes: 13 additions & 0 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
30 changes: 10 additions & 20 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,25 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress'],
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
68 changes: 35 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
{
"name": "form-example",
"name": "forms-example",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"build": "ng build",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^2.1.0",
"@angular/compiler": "^2.1.0",
"@angular/core": "^2.1.0",
"@angular/forms": "^2.1.0",
"@angular/http": "^2.1.0",
"@angular/platform-browser": "^2.1.0",
"@angular/platform-browser-dynamic": "^2.1.0",
"@angular/router": "^3.1.0",
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "^2.1.0",
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.20-4",
"codelyzer": "~1.0.0-beta.3",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
"@angular/cli": "1.2.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
14 changes: 5 additions & 9 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
// https://github.com/angular/protractor/blob/master/lib/config.ts

/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
Expand All @@ -20,13 +19,10 @@ exports.config = {
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
onPrepare() {
require('ts-node').register({
project: 'e2e'
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
32 changes: 30 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<h1>My form!</h1>

<h4>Enter a hexadecimal value, like <span style="font-family: monospace">34d7f03</span></h4>
<h3>Enter a hexadecimal value, like <span style="font-family: monospace">34d7f03</span></h3>

<form #form="ngForm" (ngSubmit)="onSubmit(form.value)">
<h4>NgModel Ex</h4>

<form novalidate #form="ngForm" (ngSubmit)="onSubmit(form.value)">
<form-text
required
hexadecimal
maxlength="10"
name="hexadecimalValue"
label="Value 1"
placeholder="Enter a hexadecimal value"
Expand All @@ -25,4 +28,29 @@ <h4>Enter a hexadecimal value, like <span style="font-family: monospace">34d7f03
</form-select>

<button type="Submit" [disabled]="!form.valid">Submit</button>
</form>

<h4>Reactive Forms Ex</h4>

<form novalidate [formGroup]="reactiveForm" (ngSubmit)="onSubmit(reactiveForm.value)">

<form-text
name="hexadecimalValue"
label="Value 1"
placeholder="Enter a hexadecimal value"
formControlName="hexadecimalValue">
</form-text>

<form-select
name="dropdownValue"
label="Value 2"
placeholder="Select a dropdown value"
formControlName="dropdownValue">
<option [value]="1">Option One</option>
<option [value]="2">Option Two</option>
<option [value]="3">Option Three</option>
<option [value]="4">Option Four</option>
</form-select>

<button type="Submit" [disabled]="!reactiveForm.valid">Submit</button>
</form>
Loading