From 8dc2629a7fabff282f23747e1704725f3007aa8e Mon Sep 17 00:00:00 2001 From: anhtuan Date: Wed, 26 Jul 2017 16:01:38 +0700 Subject: [PATCH] replace source --- .angular-cli.json | 6 +-- README.md | 4 +- e2e/app.e2e-spec.ts | 14 +++--- e2e/app.po.ts | 2 +- e2e/tsconfig.e2e.json | 2 + package.json | 95 ++++++++++++++++++----------------- src/app/app-routing.module.ts | 15 ++++++ src/app/app.component.html | 9 ++-- src/app/app.component.scss | 5 ++ src/app/app.component.spec.ts | 6 ++- src/app/app.component.ts | 28 +---------- src/app/app.module.ts | 5 +- src/index.html | 2 +- src/polyfills.ts | 9 ++-- src/styles.scss | 1 + src/tsconfig.app.json | 2 +- src/tsconfig.spec.json | 2 +- tsconfig.json | 1 - tslint.json | 11 +++- 19 files changed, 114 insertions(+), 105 deletions(-) create mode 100644 src/app/app-routing.module.ts create mode 100644 src/app/app.component.scss create mode 100644 src/styles.scss diff --git a/.angular-cli.json b/.angular-cli.json index f907d73..5dcdb15 100644 --- a/.angular-cli.json +++ b/.angular-cli.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { - "name": "my-app" + "name": "hero-app" }, "apps": [ { @@ -19,7 +19,7 @@ "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ - "styles.css" + "styles.scss" ], "scripts": [], "environmentSource": "environments/environment.ts", @@ -51,7 +51,7 @@ } }, "defaults": { - "styleExt": "css", + "styleExt": "scss", "component": {} } } diff --git a/README.md b/README.md index 246d0d4..710af5e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MyApp +# HeroApp -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.0. +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.2.1. ## Development server diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts index 868e514..d7d4684 100644 --- a/e2e/app.e2e-spec.ts +++ b/e2e/app.e2e-spec.ts @@ -1,16 +1,14 @@ -import { MyAppPage } from './app.po'; +import { HeroAppPage } from './app.po'; -describe('my-app App', () => { - let page: MyAppPage; +describe('hero-app App', () => { + let page: HeroAppPage; beforeEach(() => { - page = new MyAppPage(); + page = new HeroAppPage(); }); - it('should display welcome message', done => { + it('should display welcome message', () => { page.navigateTo(); - page.getParagraphText() - .then(msg => expect(msg).toEqual('Welcome to app!!')) - .then(done, done.fail); + expect(page.getParagraphText()).toEqual('Welcome to app!'); }); }); diff --git a/e2e/app.po.ts b/e2e/app.po.ts index 29764d4..c7454ca 100644 --- a/e2e/app.po.ts +++ b/e2e/app.po.ts @@ -1,6 +1,6 @@ import { browser, by, element } from 'protractor'; -export class MyAppPage { +export class HeroAppPage { navigateTo() { return browser.get('/'); } diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json index e2a9a2f..1d9e5ed 100644 --- a/e2e/tsconfig.e2e.json +++ b/e2e/tsconfig.e2e.json @@ -2,10 +2,12 @@ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/e2e", + "baseUrl": "./", "module": "commonjs", "target": "es5", "types": [ "jasmine", + "jasminewd2", "node" ] } diff --git a/package.json b/package.json index 9195531..5a1ef9e 100644 --- a/package.json +++ b/package.json @@ -1,48 +1,49 @@ { - "name": "my-app", - "version": "0.0.0", - "license": "MIT", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "test": "ng test", - "lint": "ng lint", - "e2e": "ng e2e" - }, - "private": true, - "dependencies": { - "@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.1.0", - "zone.js": "^0.8.4" - }, - "devDependencies": { - "@angular/cli": "1.2.1", - "@angular/compiler-cli": "^4.0.0", - "@angular/language-service": "^4.0.0", - "@types/jasmine": "2.5.45", - "@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-jasmine": "~1.1.0", - "karma-jasmine-html-reporter": "^0.2.2", - "karma-coverage-istanbul-reporter": "^1.2.1", - "protractor": "~5.1.2", - "ts-node": "~3.0.4", - "tslint": "~5.3.2", - "typescript": "~2.3.3" - } -} \ No newline at end of file + "name": "hero-app", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@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.1.0", + "zone.js": "^0.8.4" + }, + "devDependencies": { + "@angular/cli": "1.2.1", + "@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" + } +} diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts new file mode 100644 index 0000000..5b7d25b --- /dev/null +++ b/src/app/app-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +const routes: Routes = [ + { + path: '', + children: [] + } +]; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/src/app/app.component.html b/src/app/app.component.html index d0322ef..b762c39 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,14 +1,14 @@ - +

- Welcome to {{title}}!! + Welcome to {{title}}!

- +

Here are some links to help you start:

+ diff --git a/src/app/app.component.scss b/src/app/app.component.scss new file mode 100644 index 0000000..38d74ad --- /dev/null +++ b/src/app/app.component.scss @@ -0,0 +1,5 @@ +h1 { + color: #369; + font-family: Arial, Helvetica, sans-serif; + font-size: 250; +} \ No newline at end of file diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 7d2799c..d475e2c 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,10 +1,14 @@ import { TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], declarations: [ AppComponent ], @@ -27,6 +31,6 @@ describe('AppComponent', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!!'); + expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); })); }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ad4c946..7d943bc 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -3,32 +3,8 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.css'], - template: ` -

- {{title}} -
-
- -
- -
- {{hero.name}} -

- ` - + styleUrls: ['./app.component.scss'] }) export class AppComponent { - title = 'Two-way binding with ngModel'; - hero: Hero = { - id: 1, - name: 'danger' - } -} - -export class Hero { - id: number; - name: string; + title = 'app'; } - diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b693e10..2c3ba29 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,7 +1,8 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; + +import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; -import { FormsModule } from '@angular/forms'; @NgModule({ declarations: [ @@ -9,7 +10,7 @@ import { FormsModule } from '@angular/forms'; ], imports: [ BrowserModule, - FormsModule + AppRoutingModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/index.html b/src/index.html index 0450fa5..2c43132 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - MyApp + HeroApp diff --git a/src/polyfills.ts b/src/polyfills.ts index fd01cc9..7831e97 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -37,16 +37,15 @@ /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`. -/** IE10 and IE11 requires the following to support `@angular/animation`. */ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - - /** Evergreen browsers require these. **/ import 'core-js/es6/reflect'; import 'core-js/es7/reflect'; -/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +/** + * Required to support Web Animations `@angular/animation`. + * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation + **/ // import 'web-animations-js'; // Run `npm install --save web-animations-js`. diff --git a/src/styles.scss b/src/styles.scss new file mode 100644 index 0000000..90d4ee0 --- /dev/null +++ b/src/styles.scss @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 5e2507d..39ba8db 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -2,8 +2,8 @@ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", + "baseUrl": "./", "module": "es2015", - "baseUrl": "", "types": [] }, "exclude": [ diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json index 510e3f1..63d89ff 100644 --- a/src/tsconfig.spec.json +++ b/src/tsconfig.spec.json @@ -2,9 +2,9 @@ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/spec", + "baseUrl": "./", "module": "commonjs", "target": "es5", - "baseUrl": "", "types": [ "jasmine", "node" diff --git a/tsconfig.json b/tsconfig.json index a35a8ee..1f9b558 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,6 @@ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", - "baseUrl": "src", "sourceMap": true, "declaration": false, "moduleResolution": "node", diff --git a/tslint.json b/tslint.json index dd117b3..0db5751 100644 --- a/tslint.json +++ b/tslint.json @@ -31,8 +31,14 @@ "member-access": false, "member-ordering": [ true, - "static-before-instance", - "variables-before-functions" + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } ], "no-arg": true, "no-bitwise": true, @@ -80,6 +86,7 @@ ], "radix": true, "semicolon": [ + true, "always" ], "triple-equals": [