├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── README.md
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── src
├── app
│ ├── app.component.css
│ ├── app.component.css.map
│ ├── app.component.html
│ ├── app.component.scss
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── components
│ │ ├── card-footer
│ │ │ ├── card-footer.component.css
│ │ │ ├── card-footer.component.css.map
│ │ │ ├── card-footer.component.html
│ │ │ ├── card-footer.component.scss
│ │ │ ├── card-footer.component.spec.ts
│ │ │ └── card-footer.component.ts
│ │ ├── card-header
│ │ │ ├── card-header.component.css
│ │ │ ├── card-header.component.css.map
│ │ │ ├── card-header.component.html
│ │ │ ├── card-header.component.scss
│ │ │ ├── card-header.component.spec.ts
│ │ │ └── card-header.component.ts
│ │ ├── card
│ │ │ ├── card.component.css
│ │ │ ├── card.component.css.map
│ │ │ ├── card.component.html
│ │ │ ├── card.component.scss
│ │ │ ├── card.component.spec.ts
│ │ │ └── card.component.ts
│ │ ├── trend-component
│ │ │ ├── trend-component.component.html
│ │ │ ├── trend-component.component.scss
│ │ │ ├── trend-component.component.spec.ts
│ │ │ └── trend-component.component.ts
│ │ └── trend-template
│ │ │ ├── trend-template.component.html
│ │ │ ├── trend-template.component.scss
│ │ │ ├── trend-template.component.spec.ts
│ │ │ └── trend-template.component.ts
│ ├── demo
│ │ ├── demo-animation
│ │ │ ├── demo-animation.component.css
│ │ │ ├── demo-animation.component.css.map
│ │ │ ├── demo-animation.component.html
│ │ │ ├── demo-animation.component.scss
│ │ │ ├── demo-animation.component.spec.ts
│ │ │ └── demo-animation.component.ts
│ │ ├── demo-bind
│ │ │ ├── demo-bind.component.css
│ │ │ ├── demo-bind.component.css.map
│ │ │ ├── demo-bind.component.html
│ │ │ ├── demo-bind.component.scss
│ │ │ ├── demo-bind.component.spec.ts
│ │ │ └── demo-bind.component.ts
│ │ ├── demo-child-router
│ │ │ ├── demo-child-router.component.css
│ │ │ ├── demo-child-router.component.css.map
│ │ │ ├── demo-child-router.component.html
│ │ │ ├── demo-child-router.component.scss
│ │ │ ├── demo-child-router.component.spec.ts
│ │ │ └── demo-child-router.component.ts
│ │ ├── demo-child-router2
│ │ │ ├── demo-child-router2.component.css
│ │ │ ├── demo-child-router2.component.css.map
│ │ │ ├── demo-child-router2.component.html
│ │ │ ├── demo-child-router2.component.scss
│ │ │ ├── demo-child-router2.component.spec.ts
│ │ │ └── demo-child-router2.component.ts
│ │ ├── demo-component
│ │ │ ├── demo-component.component.css
│ │ │ ├── demo-component.component.css.map
│ │ │ ├── demo-component.component.html
│ │ │ ├── demo-component.component.scss
│ │ │ ├── demo-component.component.spec.ts
│ │ │ └── demo-component.component.ts
│ │ ├── demo-directive
│ │ │ ├── demo-directive.component.css
│ │ │ ├── demo-directive.component.css.map
│ │ │ ├── demo-directive.component.html
│ │ │ ├── demo-directive.component.scss
│ │ │ ├── demo-directive.component.spec.ts
│ │ │ └── demo-directive.component.ts
│ │ ├── demo-form
│ │ │ ├── demo-form.component.css
│ │ │ ├── demo-form.component.css.map
│ │ │ ├── demo-form.component.html
│ │ │ ├── demo-form.component.scss
│ │ │ ├── demo-form.component.spec.ts
│ │ │ └── demo-form.component.ts
│ │ ├── demo-guard-child
│ │ │ ├── demo-guard-child.component.html
│ │ │ ├── demo-guard-child.component.scss
│ │ │ ├── demo-guard-child.component.spec.ts
│ │ │ └── demo-guard-child.component.ts
│ │ ├── demo-guard
│ │ │ ├── demo-guard.component.html
│ │ │ ├── demo-guard.component.scss
│ │ │ ├── demo-guard.component.spec.ts
│ │ │ └── demo-guard.component.ts
│ │ ├── demo-image
│ │ │ ├── demo-image.component.html
│ │ │ ├── demo-image.component.scss
│ │ │ ├── demo-image.component.spec.ts
│ │ │ └── demo-image.component.ts
│ │ ├── demo-input
│ │ │ ├── demo-input.component.css
│ │ │ ├── demo-input.component.css.map
│ │ │ ├── demo-input.component.html
│ │ │ ├── demo-input.component.scss
│ │ │ ├── demo-input.component.spec.ts
│ │ │ └── demo-input.component.ts
│ │ ├── demo-pipe
│ │ │ ├── demo-pipe.component.css
│ │ │ ├── demo-pipe.component.css.map
│ │ │ ├── demo-pipe.component.html
│ │ │ ├── demo-pipe.component.scss
│ │ │ ├── demo-pipe.component.spec.ts
│ │ │ └── demo-pipe.component.ts
│ │ ├── demo-router-load
│ │ │ ├── demo-router-load-routing.module.ts
│ │ │ ├── demo-router-load.component.css
│ │ │ ├── demo-router-load.component.css.map
│ │ │ ├── demo-router-load.component.html
│ │ │ ├── demo-router-load.component.scss
│ │ │ ├── demo-router-load.component.spec.ts
│ │ │ ├── demo-router-load.component.ts
│ │ │ └── demo-router-load.module.ts
│ │ ├── demo-router
│ │ │ ├── demo-router.component.css
│ │ │ ├── demo-router.component.css.map
│ │ │ ├── demo-router.component.html
│ │ │ ├── demo-router.component.scss
│ │ │ ├── demo-router.component.spec.ts
│ │ │ └── demo-router.component.ts
│ │ ├── demo-router2
│ │ │ ├── demo-router2.component.css
│ │ │ ├── demo-router2.component.css.map
│ │ │ ├── demo-router2.component.html
│ │ │ ├── demo-router2.component.scss
│ │ │ ├── demo-router2.component.spec.ts
│ │ │ └── demo-router2.component.ts
│ │ ├── demo-service
│ │ │ ├── demo-service.component.css
│ │ │ ├── demo-service.component.css.map
│ │ │ ├── demo-service.component.html
│ │ │ ├── demo-service.component.scss
│ │ │ ├── demo-service.component.spec.ts
│ │ │ └── demo-service.component.ts
│ │ ├── demo-style
│ │ │ ├── demo-style.component.css
│ │ │ ├── demo-style.component.css.map
│ │ │ ├── demo-style.component.html
│ │ │ ├── demo-style.component.scss
│ │ │ ├── demo-style.component.spec.ts
│ │ │ └── demo-style.component.ts
│ │ └── demo-trend
│ │ │ ├── demo-trend.component.html
│ │ │ ├── demo-trend.component.scss
│ │ │ ├── demo-trend.component.spec.ts
│ │ │ └── demo-trend.component.ts
│ ├── directive
│ │ ├── button
│ │ │ ├── button.directive.spec.ts
│ │ │ └── button.directive.ts
│ │ └── my-if
│ │ │ ├── my-if.directive.spec.ts
│ │ │ └── my-if.directive.ts
│ ├── guard
│ │ ├── auth.guard.ts
│ │ ├── authChildGuard.ts
│ │ └── canDeactivateGuard.ts
│ ├── modules
│ │ └── app-routing.module.ts
│ ├── pipes
│ │ ├── sort.pipe.spec.ts
│ │ └── sort.pipe.ts
│ └── service
│ │ ├── book.json
│ │ ├── book.service.spec.ts
│ │ └── book.service.ts
├── assets
│ ├── .gitkeep
│ └── a.gif
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── styles.css.map
├── styles.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── typings.d.ts
├── tsconfig.json
└── tslint.json
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "angular-demo"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "scss",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.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 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 《[Angular 实战系列](http://ghmagical.com/article/page/id/6iaMdDWC8J9k)》目前处于章节不定,内容不定阶段,这一系列文章不会长篇大论的讲解概念,而是以用为主,结合通俗易懂的实例来让大家理解常用的知识点。
2 |
3 | **章节**
4 |
5 | - [Angular CLI](http://ghmagical.com/article/page/id/na7zoYaTCXmK)
6 |
7 | - [创建组件(Component)](http://ghmagical.com/article/page/id/rpnjrjgb2VKk)
8 |
9 | - [使用CSS美化组件](http://ghmagical.com/article/page/id/5e3u4IANqDEu)
10 |
11 | - [属性和事件绑定](http://ghmagical.com/article/page/id/jn8WEZ0PEgqM)
12 |
13 | - [组件通讯(@Input和@Output)](http://ghmagical.com/article/page/id/RqwseHjX47oL)
14 |
15 | - [创建指令(Directive)](http://ghmagical.com/article/page/id/RgIvn9Pai3ks)
16 |
17 | - [创建服务(Service)](http://ghmagical.com/article/page/id/GaxxslSZ6G0T)
18 |
19 | - [创建管道(Pipe)](http://ghmagical.com/article/page/id/PvBmvywEA0Hi)
20 |
21 | - [创建表单](http://ghmagical.com/article/page/id/m0X2y65L8JKX)
22 |
23 | - [路由导航(Router)](http://ghmagical.com/article/page/id/xIT4VfvbWHXi)
24 |
25 | - [动画(Animation)](http://ghmagical.com/article/page/id/MdysVNc4H22K)
26 |
27 | - [安全路由](http://ghmagical.com/article/page/id/b8uJOlMvlQDA)
28 |
29 | - 动态模板和动态组件
30 |
31 | 下载下来后,需要如下步骤启动项目:
32 | - 打开终端
33 | - 输入以下命令
34 | ```
35 | cd angular-demo
36 |
37 | npm install
38 |
39 | npm start
40 | ```
41 | 当然,你首先要安装`@angular/cli`,如果还没安装,可以看第一章《[Angular CLI](http://ghmagical.com/article/page/id/na7zoYaTCXmK)》。
42 |
43 | 原文链接:[Angular4 实战开发](http://ghmagical.com/article/page/id/6iaMdDWC8J9k)
44 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AngularDemoPage } from './app.po';
2 |
3 | describe('angular-demo App', () => {
4 | let page: AngularDemoPage;
5 |
6 | beforeEach(() => {
7 | page = new AngularDemoPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class AngularDemoPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types":[
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/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-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-demo",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^4.1.3",
16 | "@angular/common": "^4.0.0",
17 | "@angular/compiler": "^4.0.0",
18 | "@angular/core": "^4.0.0",
19 | "@angular/forms": "^4.0.0",
20 | "@angular/http": "^4.0.0",
21 | "@angular/platform-browser": "^4.0.0",
22 | "@angular/platform-browser-dynamic": "^4.0.0",
23 | "@angular/router": "^4.0.0",
24 | "core-js": "^2.4.1",
25 | "rxjs": "^5.1.0",
26 | "zone.js": "^0.8.4"
27 | },
28 | "devDependencies": {
29 | "@angular/cli": "1.0.0",
30 | "@angular/compiler-cli": "^4.0.0",
31 | "@types/jasmine": "2.5.38",
32 | "@types/node": "~6.0.60",
33 | "codelyzer": "~2.0.0",
34 | "jasmine-core": "~2.5.2",
35 | "jasmine-spec-reporter": "~3.2.0",
36 | "karma": "~1.4.1",
37 | "karma-chrome-launcher": "~2.0.0",
38 | "karma-cli": "~1.0.1",
39 | "karma-jasmine": "~1.1.0",
40 | "karma-jasmine-html-reporter": "^0.2.2",
41 | "karma-coverage-istanbul-reporter": "^0.2.0",
42 | "protractor": "~5.1.0",
43 | "ts-node": "~2.0.0",
44 | "tslint": "~4.5.0",
45 | "typescript": "~2.2.0"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/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 | './e2e/**/*.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 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
1 | :host /deep/ .main-container {
2 | position: absolute;
3 | top: 0;
4 | left: 0;
5 | right: 0;
6 | bottom: 0; }
7 | :host /deep/ .main-container,
8 | :host /deep/ .main-sidebar,
9 | :host /deep/ .main-content {
10 | position: absolute;
11 | top: 0;
12 | bottom: 0; }
13 | :host /deep/ .main-sidebar {
14 | left: 0;
15 | width: 250px;
16 | border-right: 1px solid #d9d9d9; }
17 | :host /deep/ .main-sidebar .sidebar-title {
18 | line-height: 40px;
19 | font-size: 18px;
20 | display: flex;
21 | justify-content: center;
22 | border-bottom: 1px solid #d9d9d9; }
23 | :host /deep/ .main-sidebar .sidebar-wrapper {
24 | position: absolute;
25 | top: 40px;
26 | left: 0;
27 | bottom: 0;
28 | width: 100%;
29 | overflow: hidden;
30 | overflow-y: auto; }
31 | :host /deep/ .main-sidebar .sidebar-wrapper ul > li {
32 | display: flex;
33 | line-height: 40px;
34 | align-item: center; }
35 | :host /deep/ .main-sidebar .sidebar-wrapper ul > li a {
36 | display: flex;
37 | padding-left: 30px;
38 | text-decoration: none;
39 | color: #333;
40 | flex: 1 0 auto;
41 | cursor: pointer;
42 | border-bottom: 1px solid #d9d9d9; }
43 | :host /deep/ .main-sidebar .sidebar-wrapper ul > li a:hover, :host /deep/ .main-sidebar .sidebar-wrapper ul > li a.active {
44 | background: #eee; }
45 | :host /deep/ .main-content {
46 | left: 250px;
47 | right: 0;
48 | overflow: hidden;
49 | overflow-y: auto;
50 | padding: 15px; }
51 |
52 | /*# sourceMappingURL=app.component.css.map */
53 |
--------------------------------------------------------------------------------
/src/app/app.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AACE,4BAAgB;EACd,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,CAAC;EACR,MAAM,EAAE,CAAC;AAGX;;0BAEc;EACZ,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,MAAM,EAAE,CAAC;AAGX,0BAAc;EACZ,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,KAAK;EACZ,YAAY,EAAE,iBAAiB;EAE/B,yCAAe;IACb,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,aAAa,EAAE,iBAAiB;EAGlC,2CAAiB;IACf,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,IAAI;IAEhB,mDAAQ;MACN,OAAO,EAAE,IAAI;MACb,WAAW,EAAC,IAAI;MAChB,UAAU,EAAE,MAAM;MAElB,qDAAE;QACA,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,iBAAiB;QAEhC,yHACS;UACP,UAAU,EAAE,IAAI;AAO1B,0BAAc;EACZ,IAAI,EAAE,KAAK;EACX,KAAK,EAAE,CAAC;EACR,QAAQ,EAAE,MAAM;EAChB,UAAU,EAAE,IAAI;EAChB,OAAO,EAAE,IAAI",
4 | "sources": ["app.component.scss"],
5 | "names": [],
6 | "file": "app.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
52 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | :host /deep/ {
2 | .main-container {
3 | position: absolute;
4 | top: 0;
5 | left: 0;
6 | right: 0;
7 | bottom: 0;
8 | }
9 |
10 | .main-container,
11 | .main-sidebar,
12 | .main-content {
13 | position: absolute;
14 | top: 0;
15 | bottom: 0;
16 | }
17 |
18 | .main-sidebar {
19 | left: 0;
20 | width: 250px;
21 | border-right: 1px solid #d9d9d9;
22 |
23 | .sidebar-title {
24 | line-height: 40px;
25 | font-size: 18px;
26 | display: flex;
27 | justify-content: center;
28 | border-bottom: 1px solid #d9d9d9;
29 | }
30 |
31 | .sidebar-wrapper {
32 | position: absolute;
33 | top: 40px;
34 | left: 0;
35 | bottom: 0;
36 | width: 100%;
37 | overflow: hidden;
38 | overflow-y: auto;
39 |
40 | ul > li {
41 | display: flex;
42 | line-height:40px;
43 | align-item: center;
44 |
45 | a {
46 | display: flex;
47 | padding-left: 30px;
48 | text-decoration: none;
49 | color: #333;
50 | flex: 1 0 auto;
51 | cursor: pointer;
52 | border-bottom: 1px solid #d9d9d9;
53 |
54 | &:hover,
55 | &.active {
56 | background: #eee;
57 | }
58 | }
59 | }
60 | }
61 | }
62 |
63 | .main-content {
64 | left: 250px;
65 | right: 0;
66 | overflow: hidden;
67 | overflow-y: auto;
68 | padding: 15px;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 | title = 'app works!';
10 | }
11 |
--------------------------------------------------------------------------------
/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 { HttpModule } from '@angular/http';
5 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
6 |
7 | import { AppComponent } from './app.component';
8 | import {AppRoutingModule} from './modules/app-routing.module';
9 | import { DemoComponentComponent } from './demo/demo-component/demo-component.component';
10 | import { CardComponent } from './components/card/card.component';
11 | import { DemoStyleComponent } from './demo/demo-style/demo-style.component';
12 | import { CardHeaderComponent } from './components/card-header/card-header.component';
13 | import { DemoBindComponent } from './demo/demo-bind/demo-bind.component';
14 | import { DemoInputComponent } from './demo/demo-input/demo-input.component';
15 | import { CardFooterComponent } from './components/card-footer/card-footer.component';
16 | import { ButtonDirective } from './directive/button/button.directive';
17 | import { DemoDirectiveComponent } from './demo/demo-directive/demo-directive.component';
18 | import { MyIfDirective } from './directive/my-if/my-if.directive';
19 | import { DemoPipeComponent } from './demo/demo-pipe/demo-pipe.component';
20 | import { SortPipe } from './pipes/sort.pipe';
21 | import { DemoServiceComponent } from './demo/demo-service/demo-service.component';
22 | import { DemoFormComponent } from './demo/demo-form/demo-form.component';
23 | import { DemoRouterComponent } from './demo/demo-router/demo-router.component';
24 | import { DemoAnimationComponent } from './demo/demo-animation/demo-animation.component';
25 | import { DemoRouter2Component } from './demo/demo-router2/demo-router2.component';
26 | import { DemoChildRouterComponent } from './demo/demo-child-router/demo-child-router.component';
27 | import { DemoChildRouter2Component } from './demo/demo-child-router2/demo-child-router2.component';
28 | import { DemoGuardComponent } from './demo/demo-guard/demo-guard.component';
29 | import { DemoImageComponent } from './demo/demo-image/demo-image.component';
30 | import { DemoGuardChildComponent } from './demo/demo-guard-child/demo-guard-child.component';
31 | import { DemoTrendComponent } from './demo/demo-trend/demo-trend.component';
32 | import { TrendTemplateComponent } from './components/trend-template/trend-template.component';
33 | import { TrendComponentComponent } from './components/trend-component/trend-component.component';
34 |
35 | @NgModule({
36 | declarations: [
37 | AppComponent,
38 | DemoComponentComponent,
39 | CardComponent,
40 | DemoStyleComponent,
41 | CardHeaderComponent,
42 | DemoBindComponent,
43 | DemoInputComponent,
44 | CardFooterComponent,
45 | ButtonDirective,
46 | DemoDirectiveComponent,
47 | MyIfDirective,
48 | DemoPipeComponent,
49 | SortPipe,
50 | DemoServiceComponent,
51 | DemoFormComponent,
52 | DemoRouterComponent,
53 | DemoAnimationComponent,
54 | DemoRouter2Component,
55 | DemoChildRouterComponent,
56 | DemoChildRouter2Component,
57 | DemoGuardComponent,
58 | DemoImageComponent,
59 | DemoGuardChildComponent,
60 | DemoTrendComponent,
61 | TrendTemplateComponent,
62 | TrendComponentComponent
63 | ],
64 | imports: [
65 | BrowserModule,
66 | FormsModule,
67 | HttpModule,
68 | AppRoutingModule,
69 | BrowserAnimationsModule
70 | ],
71 | entryComponents: [TrendComponentComponent],
72 | providers: [],
73 | bootstrap: [AppComponent]
74 | })
75 | export class AppModule { }
76 |
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=card-footer.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "card-footer.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/components/card-footer/card-footer.component.scss
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { CardFooterComponent } from './card-footer.component';
4 |
5 | describe('CardFooterComponent', () => {
6 | let component: CardFooterComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ CardFooterComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(CardFooterComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/card-footer/card-footer.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-card-footer',
5 | templateUrl: './card-footer.component.html',
6 | styleUrls: ['./card-footer.component.scss']
7 | })
8 | export class CardFooterComponent implements OnInit {
9 |
10 | @Output() onChange: EventEmitter = new EventEmitter();
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | onBlur(value: string) {
17 | this.onChange.emit(value); // 传播事件
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=card-header.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "card-header.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/components/card-header/card-header.component.scss
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { CardHeaderComponent } from './card-header.component';
4 |
5 | describe('CardHeaderComponent', () => {
6 | let component: CardHeaderComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ CardHeaderComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(CardHeaderComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/card-header/card-header.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-card-header',
5 | templateUrl: './card-header.component.html',
6 | styleUrls: ['./card-header.component.scss'],
7 | inputs: ['content']
8 | })
9 | export class CardHeaderComponent implements OnInit {
10 |
11 | @Input() title: string;
12 | content: string;
13 |
14 | _count: number;
15 | @Input()
16 | set count(value: number) {
17 | this._count = value + 1;
18 | }
19 | get count(): number {
20 | return this._count;
21 | }
22 | constructor() { }
23 |
24 | ngOnInit() {
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/app/components/card/card.component.css:
--------------------------------------------------------------------------------
1 | .card {
2 | padding: 10px;
3 | box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
4 | margin: 10px 0; }
5 |
6 | :host {
7 | display: block;
8 | margin: 10px 0;
9 | background: #eee; }
10 |
11 | :host(.active) {
12 | background: red; }
13 |
14 | :host-context(.theme-blue) {
15 | color: blue; }
16 |
17 | /deep/ .card-header {
18 | font-size: 25px; }
19 |
20 | /*# sourceMappingURL=card.component.css.map */
21 |
--------------------------------------------------------------------------------
/src/app/components/card/card.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AAAA,KAAM;EACJ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,0BAAsB;EAClC,MAAM,EAAE,MAAM;;AAGhB,KAAM;EACJ,OAAO,EAAE,KAAK;EACd,MAAM,EAAE,MAAM;EACd,UAAU,EAAE,IAAI;;AAElB,cAAe;EACb,UAAU,EAAE,GAAG;;AAGjB,0BAA2B;EACzB,KAAK,EAAE,IAAI;;AAEb,mBAAoB;EAClB,SAAS,EAAE,IAAI",
4 | "sources": ["card.component.scss"],
5 | "names": [],
6 | "file": "card.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/components/card/card.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | card works!
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/app/components/card/card.component.scss:
--------------------------------------------------------------------------------
1 | .card {
2 | padding: 10px;
3 | box-shadow: 0 0 3px rgba(0,0,0,.2);
4 | margin: 10px 0;
5 | }
6 |
7 | :host {
8 | display: block;
9 | margin: 10px 0;
10 | background: #eee;
11 | }
12 | :host(.active) {
13 | background: red;
14 | }
15 |
16 | :host-context(.theme-blue) {
17 | color: blue;
18 | }
19 | /deep/ .card-header {
20 | font-size: 25px;
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/components/card/card.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { CardComponent } from './card.component';
4 |
5 | describe('CardComponent', () => {
6 | let component: CardComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ CardComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(CardComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/card/card.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-card',
5 | templateUrl: './card.component.html',
6 | styleUrls: ['./card.component.scss']
7 | })
8 | export class CardComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/components/trend-component/trend-component.component.html:
--------------------------------------------------------------------------------
1 |
2 | {{title}}
3 |
4 |
--------------------------------------------------------------------------------
/src/app/components/trend-component/trend-component.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/components/trend-component/trend-component.component.scss
--------------------------------------------------------------------------------
/src/app/components/trend-component/trend-component.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { TrendComponentComponent } from './trend-component.component';
4 |
5 | describe('TrendComponentComponent', () => {
6 | let component: TrendComponentComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ TrendComponentComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(TrendComponentComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/trend-component/trend-component.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-trend-component',
5 | templateUrl: './trend-component.component.html',
6 | styleUrls: ['./trend-component.component.scss']
7 | })
8 | export class TrendComponentComponent implements OnInit {
9 |
10 | title: string;
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/components/trend-template/trend-template.component.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/components/trend-template/trend-template.component.html
--------------------------------------------------------------------------------
/src/app/components/trend-template/trend-template.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/components/trend-template/trend-template.component.scss
--------------------------------------------------------------------------------
/src/app/components/trend-template/trend-template.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { TrendTemplateComponent } from './trend-template.component';
4 |
5 | describe('TrendTemplateComponent', () => {
6 | let component: TrendTemplateComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ TrendTemplateComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(TrendTemplateComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/trend-template/trend-template.component.ts:
--------------------------------------------------------------------------------
1 | import {Component, OnInit, ViewContainerRef, Input, TemplateRef} from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-trend-template',
5 | templateUrl: './trend-template.component.html',
6 | styleUrls: ['./trend-template.component.scss']
7 | })
8 | export class TrendTemplateComponent implements OnInit {
9 |
10 | @Input() template: any;
11 | constructor(private _viewContainerRef: ViewContainerRef) { }
12 |
13 | ngOnInit() {
14 | if (this.template) {
15 | this._viewContainerRef.createEmbeddedView(this.template);
16 | }
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-animation.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-animation.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
13 |
19 |
20 |
21 |
22 |
25 |
{{state}}
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-animation/demo-animation.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoAnimationComponent } from './demo-animation.component';
4 |
5 | describe('DemoAnimationComponent', () => {
6 | let component: DemoAnimationComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoAnimationComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoAnimationComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-animation/demo-animation.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import {
3 | trigger,
4 | state,
5 | style,
6 | animate,
7 | transition
8 | } from '@angular/animations';
9 |
10 | @Component({
11 | selector: 'app-demo-animation',
12 | templateUrl: './demo-animation.component.html',
13 | styleUrls: ['./demo-animation.component.scss'],
14 | animations: [
15 | trigger('colorState', [
16 | state('active', style({
17 | background: 'red'
18 | })),
19 | state('inactive', style({
20 | background: 'blue'
21 | })),
22 | transition('active => inactive', animate('500ms ease-in')),
23 | transition('inactive => active', animate('500ms ease-out'))
24 | ]),
25 |
26 | trigger('moveInState', [
27 | state('in', style({opacity: 1, transform: 'translate3d(0,0,0)'})),
28 | transition('void => *', [
29 | style({transform: 'translate3d(0, 100px, 0)', opacity: 0}),
30 | animate(200)
31 | ]),
32 | transition('* => void', [
33 | animate(200, style({transform: 'translate3d(0, 100px, 0)', opacity: 0}))
34 | ])
35 | ]),
36 |
37 | trigger('expandState', [
38 | state('active', style({
39 | height: '*'
40 | })),
41 | state('inactive', style({
42 | height: 0
43 | })),
44 | transition('active <=> inactive', animate('300ms ease'))
45 | ])
46 | ]
47 | })
48 | export class DemoAnimationComponent implements OnInit {
49 |
50 | isActive: boolean;
51 | isIn: boolean;
52 | isExpand: boolean;
53 | expandClass: string;
54 |
55 | isExpand2: boolean;
56 | expandClass2: string;
57 | state: string;
58 | constructor() { }
59 |
60 | ngOnInit() {
61 | this.expandClass = this.isExpand ? 'active' : 'inactive';
62 | this.expandClass2 = this.isExpand2 ? 'active' : 'inactive';
63 | }
64 |
65 | toActive() {
66 | this.isActive = !this.isActive;
67 | }
68 |
69 | toIn() {
70 | this.isIn = !this.isIn;
71 | }
72 |
73 | open() {
74 | this.isExpand = !this.isExpand;
75 | this.expandClass = this.isExpand ? 'active' : 'inactive';
76 | }
77 |
78 | open2() {
79 | this.isExpand2 = !this.isExpand2;
80 | this.expandClass2 = this.isExpand2 ? 'active' : 'inactive';
81 | }
82 |
83 | transitionStart(event: any) {
84 | this.state = '动画开始';
85 | console.log(event);
86 | }
87 |
88 | transitionEnd(event: any) {
89 | this.state = '动画结束';
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.css:
--------------------------------------------------------------------------------
1 | button {
2 | padding: 5px 10px;
3 | margin-top: 10px; }
4 |
5 | div.active {
6 | border: 2px solid blue; }
7 |
8 | div {
9 | margin-top: 15px; }
10 |
11 | td {
12 | border: 1px solid #d9d9d9;
13 | padding: 10px; }
14 |
15 | /*# sourceMappingURL=demo-bind.component.css.map */
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AAAA,MAAO;EACL,OAAO,EAAE,QAAQ;EACjB,UAAU,EAAE,IAAI;;AAGlB,UAAW;EACT,MAAM,EAAE,cAAc;;AAGxB,GAAI;EACF,UAAU,EAAE,IAAI;;AAIlB,EAAG;EACD,MAAM,EAAE,iBAAiB;EACzB,OAAO,EAAE,IAAI",
4 | "sources": ["demo-bind.component.scss"],
5 | "names": [],
6 | "file": "demo-bind.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CSS类属性
7 |
8 |
9 | 单个Active类
10 |
11 | 样式属性
12 |
13 | 设置单个style
14 |
15 |
16 |
17 |
18 |
19 | one |
20 | two |
21 |
22 | One-Two |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
44 |
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.scss:
--------------------------------------------------------------------------------
1 | button {
2 | padding: 5px 10px;
3 | margin-top: 10px;
4 | }
5 |
6 | div.active {
7 | border: 2px solid blue;
8 | }
9 |
10 | div {
11 | margin-top: 15px;
12 | }
13 |
14 |
15 | td {
16 | border: 1px solid #d9d9d9;
17 | padding: 10px;
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoBindComponent } from './demo-bind.component';
4 |
5 | describe('DemoBindComponent', () => {
6 | let component: DemoBindComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoBindComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoBindComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-bind/demo-bind.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-bind',
5 | templateUrl: './demo-bind.component.html',
6 | styleUrls: ['./demo-bind.component.scss']
7 | })
8 | export class DemoBindComponent implements OnInit {
9 |
10 | isChanged: boolean;
11 | borderClass: any;
12 | isTrue: boolean;
13 | isActive: boolean;
14 | backgroundStyle: any;
15 | name: string;
16 | tel: string;
17 | constructor() { }
18 |
19 | ngOnInit() {
20 | this.borderClass = {active: !this.isTrue};
21 |
22 | this.isActive = true;
23 |
24 | this.backgroundStyle = { 'background-color': this.isActive ? 'red' : 'blue'};
25 | }
26 |
27 | onClick() {
28 | alert('你点了我');
29 | }
30 |
31 | onBlur(event: any) {
32 | alert(event.target.value);
33 | }
34 |
35 | modelChagne() {
36 | alert(this.tel);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-child-router.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-child-router.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.html:
--------------------------------------------------------------------------------
1 |
2 | 我是子路由
3 |
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-child-router/demo-child-router.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoChildRouterComponent } from './demo-child-router.component';
4 |
5 | describe('DemoChildRouterComponent', () => {
6 | let component: DemoChildRouterComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoChildRouterComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoChildRouterComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router/demo-child-router.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-child-router',
5 | templateUrl: './demo-child-router.component.html',
6 | styleUrls: ['./demo-child-router.component.scss']
7 | })
8 | export class DemoChildRouterComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-child-router2.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-child-router2.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.html:
--------------------------------------------------------------------------------
1 |
2 | 我是会动的路由视图
3 |
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-child-router2/demo-child-router2.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoChildRouter2Component } from './demo-child-router2.component';
4 |
5 | describe('DemoChildRouter2Component', () => {
6 | let component: DemoChildRouter2Component;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoChildRouter2Component ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoChildRouter2Component);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-child-router2/demo-child-router2.component.ts:
--------------------------------------------------------------------------------
1 | import {Component, HostBinding, OnInit} from '@angular/core';
2 | import {animate, state, style, trigger, transition} from '@angular/animations';
3 |
4 | @Component({
5 | selector: 'app-demo-child-router2',
6 | templateUrl: './demo-child-router2.component.html',
7 | styleUrls: ['./demo-child-router2.component.scss'],
8 | animations: [
9 | trigger('fadeInUpState', [
10 | state('in', style({opacity: 1, transform: 'translate3d(0, 0, 0)'})),
11 | transition('void => *', [
12 | style({
13 | opacity: 0,
14 | transform: 'translate3d(0, 100%, 0)'
15 | }), animate('.4s cubic-bezier(.25,.8,.25,1)')
16 | ])
17 | ])
18 | ]
19 | })
20 | export class DemoChildRouter2Component implements OnInit {
21 |
22 | @HostBinding('@fadeInUpState') fadeInUpState;
23 | @HostBinding('style.display') display = 'block';
24 | constructor() { }
25 |
26 | ngOnInit() {
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-component.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-component.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 卡头
5 | 我是卡的内容
6 |
7 |
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.scss:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoComponentComponent } from './demo-component.component';
4 |
5 | describe('DemoComponentComponent', () => {
6 | let component: DemoComponentComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoComponentComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoComponentComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-component/demo-component.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-component',
5 | templateUrl: './demo-component.component.html',
6 | styleUrls: ['./demo-component.component.scss']
7 | })
8 | export class DemoComponentComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.css:
--------------------------------------------------------------------------------
1 | button {
2 | margin: 10px; }
3 |
4 | /*# sourceMappingURL=demo-directive.component.css.map */
5 |
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AAAA,MAAO;EACL,MAAM,EAAE,IAAI",
4 | "sources": ["demo-directive.component.scss"],
5 | "names": [],
6 | "file": "demo-directive.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
ngIf结构型指令
9 |
10 |
11 |
12 |
13 |
ngIf结构型指令中的else
14 |
else效果
15 |
16 |
17 |
18 |
24 |
25 |
26 |
带索引
27 |
28 | - {{i + ':' + book}}
29 |
30 |
31 |
32 |
33 |
ngSwitch
34 |
39 |
40 |
汪
41 |
喵
42 |
哼
43 |
44 |
45 |
46 |
47 |
自定义结构型指令
48 |
49 |
自定义结构型指令appMyIf
50 |
51 |
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.scss:
--------------------------------------------------------------------------------
1 | button {
2 | margin: 10px;
3 | }
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoDirectiveComponent } from './demo-directive.component';
4 |
5 | describe('DemoDirectiveComponent', () => {
6 | let component: DemoDirectiveComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoDirectiveComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoDirectiveComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-directive/demo-directive.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-directive',
5 | templateUrl: './demo-directive.component.html',
6 | styleUrls: ['./demo-directive.component.scss']
7 | })
8 | export class DemoDirectiveComponent implements OnInit {
9 |
10 | isShow: boolean;
11 | books: any;
12 | isShowElse: boolean;
13 | animal: string;
14 | isMyShow: boolean;
15 | constructor() { }
16 |
17 | ngOnInit() {
18 | this.isShowElse = true;
19 | this.books = ['HTML', 'Javascript'];
20 |
21 | this.animal = 'dog';
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.css:
--------------------------------------------------------------------------------
1 | input.ng-invalid {
2 | border: 1px solid red; }
3 |
4 | .error {
5 | color: red; }
6 |
7 | /*# sourceMappingURL=demo-form.component.css.map */
8 |
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AAAA,gBAAiB;EACf,MAAM,EAAE,aAAa;;AAGvB,MAAO;EACL,KAAK,EAAE,GAAG",
4 | "sources": ["demo-form.component.scss"],
5 | "names": [],
6 | "file": "demo-form.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.html:
--------------------------------------------------------------------------------
1 |
28 |
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.scss:
--------------------------------------------------------------------------------
1 | input.ng-invalid {
2 | border: 1px solid red;
3 | }
4 |
5 | .error {
6 | color: red;
7 | }
8 |
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoFormComponent } from './demo-form.component';
4 |
5 | describe('DemoFormComponent', () => {
6 | let component: DemoFormComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoFormComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoFormComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-form/demo-form.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-form',
5 | templateUrl: './demo-form.component.html',
6 | styleUrls: ['./demo-form.component.scss']
7 | })
8 | export class DemoFormComponent implements OnInit {
9 |
10 | name: string;
11 | sex: string;
12 | tel: string;
13 | constructor() { }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | onSubmit(valid: boolean) {
19 | if (valid) {
20 | alert('用户:' + this.name + ';性别:' + this.sex);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard-child/demo-guard-child.component.html:
--------------------------------------------------------------------------------
1 |
2 | 这是子路由的守卫检测
3 |
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard-child/demo-guard-child.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-guard-child/demo-guard-child.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-guard-child/demo-guard-child.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoGuardChildComponent } from './demo-guard-child.component';
4 |
5 | describe('DemoGuardChildComponent', () => {
6 | let component: DemoGuardChildComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoGuardChildComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoGuardChildComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard-child/demo-guard-child.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-guard-child',
5 | templateUrl: './demo-guard-child.component.html',
6 | styleUrls: ['./demo-guard-child.component.scss']
7 | })
8 | export class DemoGuardChildComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard/demo-guard.component.html:
--------------------------------------------------------------------------------
1 |
12 |
13 |
16 |
17 |
18 |
19 |
CanDeactivateGuard
20 |
21 | (尝试修改表单的内容,然后点击其他页面)
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard/demo-guard.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-guard/demo-guard.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-guard/demo-guard.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoGuardComponent } from './demo-guard.component';
4 |
5 | describe('DemoGuardComponent', () => {
6 | let component: DemoGuardComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoGuardComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoGuardComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-guard/demo-guard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-guard',
5 | templateUrl: './demo-guard.component.html',
6 | styleUrls: ['./demo-guard.component.scss']
7 | })
8 | export class DemoGuardComponent implements OnInit {
9 |
10 | name: string = '123';
11 | constructor() {
12 | localStorage.clear();
13 | }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | onSubmit(account: string, pwd: string) {
19 | if (account === '123' && pwd === '123') {
20 | localStorage.setItem('user', JSON.stringify({account: account, password: pwd}));
21 | alert('登录成功,你可以看图片了,嘿嘿');
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-image/demo-image.component.html:
--------------------------------------------------------------------------------
1 |
2 |

3 |
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-image/demo-image.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-image/demo-image.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-image/demo-image.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoImageComponent } from './demo-image.component';
4 |
5 | describe('DemoImageComponent', () => {
6 | let component: DemoImageComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoImageComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoImageComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-image/demo-image.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-image',
5 | templateUrl: './demo-image.component.html',
6 | styleUrls: ['./demo-image.component.scss']
7 | })
8 | export class DemoImageComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-input.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-input.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.html:
--------------------------------------------------------------------------------
1 |
6 |
11 |
12 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-input/demo-input.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoInputComponent } from './demo-input.component';
4 |
5 | describe('DemoInputComponent', () => {
6 | let component: DemoInputComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoInputComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoInputComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-input/demo-input.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-input',
5 | templateUrl: './demo-input.component.html',
6 | styleUrls: ['./demo-input.component.scss']
7 | })
8 | export class DemoInputComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | onChange(event: any) {
16 | alert(event);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-pipe.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-pip.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.html:
--------------------------------------------------------------------------------
1 |
2 |
DatePipe
3 |
{{ today | date }}
4 |
{{ today | date: 'y-MM-dd'}}
5 |
6 |
7 |
8 | {{ birthday | date:format }}
9 |
10 |
11 |
12 |
13 |
JsonPipe
14 |
{{jsonObject | json}}
15 |
16 |
17 |
18 |
UpperCasePipe
19 | {{ 'aBc' | uppercase}}
20 |
21 |
22 |
23 |
LowerCasePipe
24 | {{ 'AbC' | lowercase}}
25 |
26 |
27 |
28 |
DecimalPipe
29 |
aa :{{aa | number: '3.4-5'}}
30 |
bb :{{bb | number: '3.1-5'}}
31 |
32 |
33 |
34 |
CurrencyPipe
35 |
ac :{{ ac | currency: 'USD': false }}
36 |
bc :{{ bc | currency: 'CNY': true: '3.1-3'}}
37 |
38 |
39 |
40 |
PercentPipe
41 |
ad :{{ ad | percent }}
42 |
bd :{{ bd | percent: '3.1-3' }}
43 |
44 |
45 |
46 |
SlicePipe
47 |
{{ 'abcdef' | slice: 2 : 4}}
48 |
49 |
50 | {{a}}
51 |
52 |
53 |
54 |
55 |
56 |
TitleCasePipe
57 |
{{ 'abbcd' | titlecase }}
58 |
59 |
60 |
61 |
自定义管道sort
62 |
63 |
{{a}}
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-pipe/demo-pipe.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoPipComponent } from './demo-pipe.component';
4 |
5 | describe('DemoPipComponent', () => {
6 | let component: DemoPipComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoPipComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoPipComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-pipe/demo-pipe.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-pip',
5 | templateUrl: './demo-pipe.component.html',
6 | styleUrls: ['./demo-pipe.component.scss']
7 | })
8 | export class DemoPipeComponent implements OnInit {
9 |
10 | today: any;
11 |
12 | jsonObject: Object = {firstname: 'bar', lastname: 'qux', address: {street: 'aaa', tel: [1, 2]}};
13 |
14 | aa: number = 2.718281828459045;
15 | bb: number = 33456;
16 |
17 | ac: number = 0.259;
18 | bc: number = 20.6745;
19 |
20 | ad: number = 0.279;
21 | bd: number = 0.657;
22 | birthday: any;
23 | toggle: boolean;
24 |
25 | arr: number[] = [80, 2, 5, 30];
26 |
27 | constructor() { }
28 |
29 | ngOnInit() {
30 | this.today = new Date();
31 | this.birthday = new Date();
32 | }
33 | toggleFormat() { this.toggle = !this.toggle; }
34 | get format() { return this.toggle ? 'shortDate' : 'fullDate'; }
35 | }
36 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load-routing.module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {RouterModule, Routes} from '@angular/router';
3 | import {DemoRouterLoadComponent} from './demo-router-load.component';
4 |
5 | const routes: Routes = [
6 | {
7 | path: '',
8 | component: DemoRouterLoadComponent
9 | }
10 | ]
11 | @NgModule({
12 | imports: [RouterModule.forChild(routes)],
13 | exports: [RouterModule]
14 | })
15 |
16 | export class DemoRouterLoadRougingModule {}
17 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-router-load.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-router-load.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.html:
--------------------------------------------------------------------------------
1 |
2 | 异步路由
3 |
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-router-load/demo-router-load.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoRouterLoadComponent } from './demo-router-load.component';
4 |
5 | describe('DemoRouterLoadComponent', () => {
6 | let component: DemoRouterLoadComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoRouterLoadComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoRouterLoadComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-router-load',
5 | templateUrl: './demo-router-load.component.html',
6 | styleUrls: ['./demo-router-load.component.scss']
7 | })
8 | export class DemoRouterLoadComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router-load/demo-router-load.module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {CommonModule} from '@angular/common';
3 | import {DemoRouterLoadComponent} from './demo-router-load.component';
4 | import {DemoRouterLoadRougingModule} from './demo-router-load-routing.module';
5 |
6 | @NgModule({
7 | imports: [CommonModule, DemoRouterLoadRougingModule],
8 | declarations: [DemoRouterLoadComponent]
9 | })
10 |
11 | export class RouterLoadModule {}
12 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-router.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-router.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.html:
--------------------------------------------------------------------------------
1 |
2 | 传递的参数:{{id}}
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-router/demo-router.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoRouterComponent } from './demo-router.component';
4 |
5 | describe('DemoRouterComponent', () => {
6 | let component: DemoRouterComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoRouterComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoRouterComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router/demo-router.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import {ActivatedRoute} from '@angular/router';
3 |
4 | @Component({
5 | selector: 'app-demo-router',
6 | templateUrl: './demo-router.component.html',
7 | styleUrls: ['./demo-router.component.scss']
8 | })
9 | export class DemoRouterComponent implements OnInit {
10 |
11 | id: any;
12 | constructor(private route: ActivatedRoute) {
13 | this.route.params.subscribe(param => {
14 | this.id = param['id'];
15 | })
16 | }
17 |
18 | ngOnInit() {
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-router2.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-router2.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-router2/demo-router2.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoRouter2Component } from './demo-router2.component';
4 |
5 | describe('DemoRouter2Component', () => {
6 | let component: DemoRouter2Component;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoRouter2Component ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoRouter2Component);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-router2/demo-router2.component.ts:
--------------------------------------------------------------------------------
1 | import {Component, OnInit} from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-router2',
5 | templateUrl: './demo-router2.component.html',
6 | styleUrls: ['./demo-router2.component.scss']
7 | })
8 | export class DemoRouter2Component implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-service.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-service.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.html:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-service/demo-service.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoServiceComponent } from './demo-service.component';
4 |
5 | describe('DemoServiceComponent', () => {
6 | let component: DemoServiceComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoServiceComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoServiceComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-service/demo-service.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import {BookService} from '../../service/book.service';
3 |
4 | @Component({
5 | selector: 'app-demo-service',
6 | templateUrl: './demo-service.component.html',
7 | styleUrls: ['./demo-service.component.scss'],
8 | providers: [BookService]
9 | })
10 | export class DemoServiceComponent implements OnInit {
11 |
12 | books: any[];
13 | constructor(private bookService: BookService) { }
14 |
15 | ngOnInit() {
16 | this.bookService.getBooks()
17 | .then(res => {
18 | this.books = res.books;
19 | console.log(this.books);
20 | });
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*# sourceMappingURL=demo-style.component.css.map */
4 |
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "",
4 | "sources": [],
5 | "names": [],
6 | "file": "demo-style.component.css"
7 | }
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 卡头
4 | 我是卡的内容
5 |
6 |
7 |
8 | 卡头
9 | 我是卡的内容
10 |
11 |
12 |
13 |
14 | 卡头
15 | 我是卡的内容
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-style/demo-style.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoStyleComponent } from './demo-style.component';
4 |
5 | describe('DemoStyleComponent', () => {
6 | let component: DemoStyleComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoStyleComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoStyleComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-style/demo-style.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-demo-style',
5 | templateUrl: './demo-style.component.html',
6 | styleUrls: ['./demo-style.component.scss']
7 | })
8 | export class DemoStyleComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/demo/demo-trend/demo-trend.component.html:
--------------------------------------------------------------------------------
1 |
2 |
动态模板: 注入
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
动态模板: @ViewChild
11 |
12 |
13 |
14 |
15 |
16 |
17 |
21 |
--------------------------------------------------------------------------------
/src/app/demo/demo-trend/demo-trend.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/app/demo/demo-trend/demo-trend.component.scss
--------------------------------------------------------------------------------
/src/app/demo/demo-trend/demo-trend.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DemoTrendComponent } from './demo-trend.component';
4 |
5 | describe('DemoTrendComponent', () => {
6 | let component: DemoTrendComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ DemoTrendComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DemoTrendComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/demo/demo-trend/demo-trend.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, ViewChild, ViewContainerRef, TemplateRef, ComponentFactoryResolver } from '@angular/core';
2 | import {TrendComponentComponent} from '../../components/trend-component/trend-component.component';
3 |
4 | @Component({
5 | selector: 'app-demo-trend',
6 | templateUrl: './demo-trend.component.html',
7 | styleUrls: ['./demo-trend.component.scss']
8 | })
9 | export class DemoTrendComponent implements OnInit {
10 |
11 | @ViewChild('viewcontainer', {read: ViewContainerRef}) _viewContainerRef: ViewContainerRef;
12 | @ViewChild('tpl2') template: TemplateRef;
13 |
14 | @ViewChild('trendViewContainer', {read: ViewContainerRef}) _trendViewContainerRef: ViewContainerRef;
15 | constructor(private _componentFactoryResolver: ComponentFactoryResolver) { }
16 |
17 | ngOnInit() {
18 | this._viewContainerRef.createEmbeddedView(this.template);
19 |
20 | const componentFactory = this._componentFactoryResolver.resolveComponentFactory(TrendComponentComponent);
21 | const componentRef = this._trendViewContainerRef.createComponent(componentFactory);
22 | (componentRef.instance).title = '我是动态组件';
23 | }
24 |
25 | onclick() {
26 | alert('我是动态模板中的内容');
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/directive/button/button.directive.spec.ts:
--------------------------------------------------------------------------------
1 | import { ButtonDirective } from './button.directive';
2 |
3 | describe('ButtonDirective', () => {
4 | it('should create an instance', () => {
5 | const directive = new ButtonDirective();
6 | expect(directive).toBeTruthy();
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/src/app/directive/button/button.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, ElementRef, AfterViewInit, Renderer2,
2 | HostBinding, HostListener, Input } from '@angular/core';
3 |
4 | @Directive({
5 | selector: '[appButton]'
6 | })
7 | export class ButtonDirective implements AfterViewInit {
8 |
9 | @HostBinding('style.font-size') fontSize = '20px';
10 | @HostListener('click') onClick() {
11 | alert('你点了我!');
12 | }
13 |
14 | @Input('appButton') name: string; // 定义别名
15 | constructor(private er: ElementRef, private renderer2: Renderer2) { }
16 |
17 | ngAfterViewInit() {
18 | this.renderer2.addClass(this.er.nativeElement, 'btn');
19 |
20 | if (this.name) {
21 | const text = this.renderer2.createText(this.name);
22 | this.renderer2.appendChild(this.er.nativeElement, text);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/directive/my-if/my-if.directive.spec.ts:
--------------------------------------------------------------------------------
1 | import { MyIfDirective } from './my-if.directive';
2 |
3 | describe('MyIfDirective', () => {
4 | it('should create an instance', () => {
5 | const directive = new MyIfDirective();
6 | expect(directive).toBeTruthy();
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/src/app/directive/my-if/my-if.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, Input, ViewContainerRef, TemplateRef } from '@angular/core';
2 |
3 | @Directive({
4 | selector: '[appMyIf]'
5 | })
6 | export class MyIfDirective {
7 |
8 | constructor(private templateRef: TemplateRef,
9 | private viewContainer: ViewContainerRef) { }
10 |
11 | @Input() set appMyIf(condition: boolean) {
12 | if (!condition) {
13 | this.viewContainer.createEmbeddedView(this.templateRef);
14 | } else if (condition) {
15 | this.viewContainer.clear();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/guard/auth.guard.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
3 | import { Observable } from 'rxjs/Observable';
4 |
5 | @Injectable()
6 | export class AuthGuard implements CanActivate {
7 | canActivate(
8 | next: ActivatedRouteSnapshot,
9 | state: RouterStateSnapshot): Observable | Promise | boolean {
10 | if (localStorage.getItem('user')) {
11 | return true;
12 | } else {
13 | alert('请登录');
14 | return false;
15 | }
16 | // return true;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/guard/authChildGuard.ts:
--------------------------------------------------------------------------------
1 | import {ActivatedRouteSnapshot, CanActivateChild, RouterStateSnapshot} from '@angular/router';
2 | import {Observable} from 'rxjs/Observable';
3 | import {Injectable} from '@angular/core';
4 |
5 | @Injectable()
6 | export class AuthChildGuard implements CanActivateChild {
7 | canActivateChild(
8 | route: ActivatedRouteSnapshot,
9 | state: RouterStateSnapshot): Observable | Promise | boolean {
10 | if (localStorage.getItem('user')) {
11 | return true;
12 | } else {
13 | alert('请登录');
14 | return false;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/guard/canDeactivateGuard.ts:
--------------------------------------------------------------------------------
1 | import {ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot} from '@angular/router';
2 | import {Injectable} from '@angular/core';
3 | import {DemoGuardComponent} from '../demo/demo-guard/demo-guard.component';
4 |
5 | @Injectable()
6 | export class CanDeactivateGuard implements CanDeactivate {
7 |
8 | oldName: string = '123';
9 | canDeactivate(component: DemoGuardComponent,
10 | route: ActivatedRouteSnapshot,
11 | state: RouterStateSnapshot): Promise | boolean {
12 | if (this.oldName === component.name) {
13 | return true;
14 | }
15 | return confirm('信息未保存,确认要离开!');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/modules/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {Routes, RouterModule} from '@angular/router';
3 | import {DemoComponentComponent} from '../demo/demo-component/demo-component.component';
4 | import {DemoStyleComponent} from '../demo/demo-style/demo-style.component';
5 | import {DemoBindComponent} from '../demo/demo-bind/demo-bind.component';
6 | import {DemoInputComponent} from '../demo/demo-input/demo-input.component';
7 | import {DemoDirectiveComponent} from '../demo/demo-directive/demo-directive.component';
8 | import {DemoPipeComponent} from '../demo/demo-pipe/demo-pipe.component';
9 | import {DemoServiceComponent} from '../demo/demo-service/demo-service.component';
10 | import {DemoAnimationComponent} from '../demo/demo-animation/demo-animation.component';
11 | import {DemoRouterComponent} from '../demo/demo-router/demo-router.component';
12 | import {DemoFormComponent} from '../demo/demo-form/demo-form.component';
13 | import {DemoRouter2Component} from '../demo/demo-router2/demo-router2.component';
14 | import {DemoChildRouterComponent} from '../demo/demo-child-router/demo-child-router.component';
15 | import {DemoChildRouter2Component} from '../demo/demo-child-router2/demo-child-router2.component';
16 | import {DemoGuardComponent} from '../demo/demo-guard/demo-guard.component';
17 | import {DemoImageComponent} from '../demo/demo-image/demo-image.component';
18 | import {AuthGuard} from '../guard/auth.guard';
19 | import {DemoGuardChildComponent} from '../demo/demo-guard-child/demo-guard-child.component';
20 | import {AuthChildGuard} from '../guard/authChildGuard';
21 | import {CanDeactivateGuard} from "../guard/canDeactivateGuard";
22 | import {DemoTrendComponent} from '../demo/demo-trend/demo-trend.component';
23 |
24 | const routes: Routes = [
25 | {path: 'demoComponent', component: DemoComponentComponent},
26 | {path: 'demoStyle', component: DemoStyleComponent},
27 | {path: 'demoBind', component: DemoBindComponent},
28 | {path: 'demoInput', component: DemoInputComponent},
29 | {path: 'demoDirective', component: DemoDirectiveComponent},
30 | {path: 'demoService', component: DemoServiceComponent},
31 | {path: 'demoPipe', component: DemoPipeComponent},
32 | {path: 'demoForm', component: DemoFormComponent},
33 | {path: 'demoRouter/:id', component: DemoRouterComponent},
34 | {
35 | path: 'demoRouter2',
36 | component: DemoRouter2Component,
37 | children: [{
38 | path: 'child',
39 | component: DemoChildRouterComponent
40 | }, {
41 | path: 'child2',
42 | component: DemoChildRouter2Component
43 | }, {
44 | path: 'loadModule',
45 | loadChildren: '../demo/demo-router-load/demo-router-load.module#RouterLoadModule',
46 | }]
47 | },
48 | {path: 'demoAnimation', component: DemoAnimationComponent},
49 | {
50 | path: 'demoGuard',
51 | component: DemoGuardComponent,
52 | canDeactivate: [CanDeactivateGuard],
53 | children: [
54 | {
55 | path: '',
56 | canActivateChild: [AuthChildGuard],
57 | children: [
58 | {path: 'child', component: DemoGuardChildComponent}
59 | ]
60 | }
61 | ]
62 | },
63 | {
64 | path: 'images',
65 | canActivate: [AuthGuard],
66 | component: DemoImageComponent
67 | },
68 | {path: 'demoTrend', component: DemoTrendComponent},
69 | {path: '**', component: DemoComponentComponent}
70 | ];
71 |
72 | @NgModule({
73 | imports: [
74 | RouterModule.forRoot(routes)
75 | ],
76 | exports: [RouterModule],
77 | providers: [AuthGuard, AuthChildGuard, CanDeactivateGuard]
78 | })
79 | export class AppRoutingModule {
80 | }
81 |
--------------------------------------------------------------------------------
/src/app/pipes/sort.pipe.spec.ts:
--------------------------------------------------------------------------------
1 | import { SortPipe } from './sort.pipe';
2 |
3 | describe('SortPipe', () => {
4 | it('create an instance', () => {
5 | const pipe = new SortPipe();
6 | expect(pipe).toBeTruthy();
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/src/app/pipes/sort.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | @Pipe({
4 | name: 'sort'
5 | })
6 | export class SortPipe implements PipeTransform {
7 |
8 | transform(array: Array, args?: string): Array {
9 | array.sort((a: any, b: any) => {
10 | if (a < b) {
11 | return -1;
12 | } else if (a > b) {
13 | return 1;
14 | } else {
15 | return 0;
16 | }
17 | });
18 | return array;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/service/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "books": [
3 | {
4 | "name": "HTML"
5 | },
6 | {
7 | "name": "Javascript"
8 | },
9 | {
10 | "name": "Angular"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/service/book.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { BookService } from './book.service';
4 |
5 | describe('BookService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [BookService]
9 | });
10 | });
11 |
12 | it('should ...', inject([BookService], (service: BookService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/src/app/service/book.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import {Http} from '@angular/http';
3 | import 'rxjs/add/operator/toPromise';
4 |
5 | @Injectable()
6 | export class BookService {
7 |
8 | constructor(private http: Http) { }
9 |
10 | getBooks() {
11 | const url = '/src/app/service/book.json';
12 | return this.http.get(url)
13 | .toPromise()
14 | .then(res => res.json())
15 | .catch(this.handleError);
16 | }
17 |
18 | private handleError(error: any): Promise {
19 | console.error('An error occurred', error); // for demo purposes only
20 | return Promise.reject(error.message || error);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/assets/a.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/assets/a.gif
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/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/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IronPans/angular-demo/7fe7ac0431e5409fb041fd51b3e5dc94423e318c/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AngularDemo
6 |
7 |
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/set';
35 |
36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
37 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
38 |
39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */
40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
41 |
42 |
43 | /** Evergreen browsers require these. **/
44 | import 'core-js/es6/reflect';
45 | import 'core-js/es7/reflect';
46 |
47 |
48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/
49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50 |
51 |
52 |
53 | /***************************************************************************************************
54 | * Zone JS is required by Angular itself.
55 | */
56 | import 'zone.js/dist/zone'; // Included with Angular CLI.
57 |
58 |
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
64 | /**
65 | * Date, currency, decimal and percent pipes.
66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67 | */
68 | // import 'intl'; // Run `npm install --save intl`.
69 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | * {
3 | margin: 0;
4 | padding: 0;
5 | box-sizing: border-box; }
6 |
7 | body {
8 | font: 15px/1.2 'Microsoft Yahei'; }
9 |
10 | /* Scrollbar */
11 | ::-webkit-scrollbar {
12 | width: 10px;
13 | height: 10px; }
14 |
15 | ::-webkit-scrollbar-track,
16 | ::-webkit-scrollbar-thumb {
17 | border-right: 1px solid transparent;
18 | border-left: 1px solid transparent; }
19 |
20 | ::-webkit-scrollbar-thumb {
21 | -webkit-border-radius: 8px;
22 | border-radius: 8px;
23 | background-color: rgba(0, 0, 0, 0.2); }
24 |
25 | ::-webkit-scrollbar-corner {
26 | display: block; }
27 |
28 | ::-webkit-scrollbar-track:hover {
29 | background-color: rgba(0, 0, 0, 0.15); }
30 |
31 | ::-webkit-scrollbar-thumb:hover {
32 | -webkit-border-radius: 8px;
33 | border-radius: 8px;
34 | background-color: rgba(0, 0, 0, 0.5); }
35 |
36 | button.btn {
37 | padding: 10px;
38 | background: blue;
39 | color: #fff;
40 | border-radius: 4px;
41 | border: none; }
42 |
43 | .box {
44 | padding: 10px;
45 | box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
46 | margin: 10px; }
47 | .box > h4 {
48 | padding-bottom: 10px; }
49 |
50 | /*# sourceMappingURL=styles.css.map */
51 |
--------------------------------------------------------------------------------
/src/styles.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "mappings": "AAAA,+EAA+E;AAC/E,CAAE;EACA,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,UAAU;;AAGxB,IAAK;EACH,IAAI,EAAE,0BAA0B;;AAIlC,eAAe;AAEf,mBAAoB;EAClB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;;AAGd;yBAC0B;EACxB,YAAY,EAAE,qBAAqB;EACnC,WAAW,EAAE,qBAAqB;;AAGpC,yBAA0B;EACxB,qBAAqB,EAAE,GAAG;EAC1B,aAAa,EAAE,GAAG;EAClB,gBAAgB,EAAE,kBAAkB;;AAGtC,0BAA2B;EACzB,OAAO,EAAE,KAAK;;AAGhB,+BAAgC;EAC9B,gBAAgB,EAAE,mBAAmB;;AAGvC,+BAAgC;EAC9B,qBAAqB,EAAE,GAAG;EAC1B,aAAa,EAAE,GAAG;EAClB,gBAAgB,EAAE,kBAAkB;;AAGtC,UAAW;EACT,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,IAAI;EACX,aAAa,EAAE,GAAG;EAClB,MAAM,EAAE,IAAI;;AAGd,IAAK;EACH,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,0BAAsB;EAClC,MAAM,EAAE,IAAI;EAEZ,SAAM;IACN,cAAc,EAAE,IAAI",
4 | "sources": ["styles.scss"],
5 | "names": [],
6 | "file": "styles.css"
7 | }
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | * {
3 | margin: 0;
4 | padding: 0;
5 | box-sizing: border-box;
6 | }
7 |
8 | body {
9 | font: 15px/1.2 'Microsoft Yahei';
10 | }
11 |
12 |
13 | /* Scrollbar */
14 |
15 | ::-webkit-scrollbar {
16 | width: 10px;
17 | height: 10px;
18 | }
19 |
20 | ::-webkit-scrollbar-track,
21 | ::-webkit-scrollbar-thumb {
22 | border-right: 1px solid transparent;
23 | border-left: 1px solid transparent;
24 | }
25 |
26 | ::-webkit-scrollbar-thumb {
27 | -webkit-border-radius: 8px;
28 | border-radius: 8px;
29 | background-color: rgba(0, 0, 0, 0.2);
30 | }
31 |
32 | ::-webkit-scrollbar-corner {
33 | display: block;
34 | }
35 |
36 | ::-webkit-scrollbar-track:hover {
37 | background-color: rgba(0, 0, 0, 0.15);
38 | }
39 |
40 | ::-webkit-scrollbar-thumb:hover {
41 | -webkit-border-radius: 8px;
42 | border-radius: 8px;
43 | background-color: rgba(0, 0, 0, 0.5);
44 | }
45 |
46 | button.btn {
47 | padding: 10px;
48 | background: blue;
49 | color: #fff;
50 | border-radius: 4px;
51 | border: none;
52 | }
53 |
54 | .box {
55 | padding: 10px;
56 | box-shadow: 0 0 3px rgba(0,0,0,.2);
57 | margin: 10px;
58 |
59 | &> h4 {
60 | padding-bottom: 10px;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/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/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 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
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 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "callable-types": true,
7 | "class-name": true,
8 | "comment-format": [
9 | true,
10 | "check-space"
11 | ],
12 | "curly": true,
13 | "eofline": true,
14 | "forin": true,
15 | "import-blacklist": [true, "rxjs"],
16 | "import-spacing": true,
17 | "indent": [
18 | true,
19 | "spaces"
20 | ],
21 | "interface-over-type-literal": true,
22 | "label-position": true,
23 | "max-line-length": [
24 | true,
25 | 140
26 | ],
27 | "member-access": false,
28 | "member-ordering": [
29 | true,
30 | "static-before-instance",
31 | "variables-before-functions"
32 | ],
33 | "no-arg": true,
34 | "no-bitwise": true,
35 | "no-console": [
36 | true,
37 | "debug",
38 | "info",
39 | "time",
40 | "timeEnd",
41 | "trace"
42 | ],
43 | "no-construct": true,
44 | "no-debugger": true,
45 | "no-duplicate-variable": true,
46 | "no-empty": false,
47 | "no-empty-interface": true,
48 | "no-eval": true,
49 | "no-inferrable-types": [true, "ignore-params"],
50 | "no-shadowed-variable": true,
51 | "no-string-literal": false,
52 | "no-string-throw": true,
53 | "no-switch-case-fall-through": true,
54 | "no-trailing-whitespace": true,
55 | "no-unused-expression": true,
56 | "no-use-before-declare": true,
57 | "no-var-keyword": true,
58 | "object-literal-sort-keys": false,
59 | "one-line": [
60 | true,
61 | "check-open-brace",
62 | "check-catch",
63 | "check-else",
64 | "check-whitespace"
65 | ],
66 | "prefer-const": true,
67 | "quotemark": [
68 | true,
69 | "single"
70 | ],
71 | "radix": true,
72 | "semicolon": [
73 | "always"
74 | ],
75 | "triple-equals": [
76 | true,
77 | "allow-null-check"
78 | ],
79 | "typedef-whitespace": [
80 | true,
81 | {
82 | "call-signature": "nospace",
83 | "index-signature": "nospace",
84 | "parameter": "nospace",
85 | "property-declaration": "nospace",
86 | "variable-declaration": "nospace"
87 | }
88 | ],
89 | "typeof-compare": true,
90 | "unified-signatures": true,
91 | "variable-name": false,
92 | "whitespace": [
93 | true,
94 | "check-branch",
95 | "check-decl",
96 | "check-operator",
97 | "check-separator",
98 | "check-type"
99 | ],
100 |
101 | "directive-selector": [true, "attribute", "app", "camelCase"],
102 | "component-selector": [true, "element", "app", "kebab-case"],
103 | "use-input-property-decorator": true,
104 | "use-output-property-decorator": true,
105 | "use-host-property-decorator": true,
106 | "no-input-rename": true,
107 | "no-output-rename": true,
108 | "use-life-cycle-interface": true,
109 | "use-pipe-transform-interface": true,
110 | "component-class-suffix": true,
111 | "directive-class-suffix": true,
112 | "no-access-missing-member": true,
113 | "templates-use-public": true,
114 | "invoke-injectable": true
115 | }
116 | }
117 |
--------------------------------------------------------------------------------