Skip to content

Commit f650ae4

Browse files
committedNov 27, 2018
feat(pipe-demo): leek and injection pipe demo
1 parent e4f23a7 commit f650ae4

15 files changed

+303
-0
lines changed
 

‎angular.json

+99
Original file line numberDiff line numberDiff line change
@@ -4246,6 +4246,105 @@
42464246
}
42474247
}
42484248
}
4249+
},
4250+
"pipe-demo": {
4251+
"root": "steps/pipe-demo/",
4252+
"sourceRoot": "steps/pipe-demo/src",
4253+
"projectType": "application",
4254+
"prefix": "app",
4255+
"schematics": {},
4256+
"architect": {
4257+
"build": {
4258+
"builder": "@angular-devkit/build-angular:browser",
4259+
"options": {
4260+
"outputPath": "dist/pipe-demo",
4261+
"index": "steps/pipe-demo/src/index.html",
4262+
"main": "steps/pipe-demo/src/main.ts",
4263+
"polyfills": "steps/pipe-demo/src/polyfills.ts",
4264+
"tsConfig": "steps/pipe-demo/tsconfig.app.json",
4265+
"assets": [
4266+
"steps/pipe-demo/src/favicon.ico",
4267+
"steps/pipe-demo/src/assets"
4268+
],
4269+
"styles": [
4270+
"steps/pipe-demo/src/styles.css"
4271+
],
4272+
"scripts": []
4273+
},
4274+
"configurations": {
4275+
"production": {
4276+
"fileReplacements": [
4277+
{
4278+
"replace": "steps/pipe-demo/src/environments/environment.ts",
4279+
"with": "steps/pipe-demo/src/environments/environment.prod.ts"
4280+
}
4281+
],
4282+
"optimization": true,
4283+
"outputHashing": "all",
4284+
"sourceMap": false,
4285+
"extractCss": true,
4286+
"namedChunks": false,
4287+
"aot": true,
4288+
"extractLicenses": true,
4289+
"vendorChunk": false,
4290+
"buildOptimizer": true,
4291+
"budgets": [
4292+
{
4293+
"type": "initial",
4294+
"maximumWarning": "2mb",
4295+
"maximumError": "5mb"
4296+
}
4297+
]
4298+
}
4299+
}
4300+
},
4301+
"serve": {
4302+
"builder": "@angular-devkit/build-angular:dev-server",
4303+
"options": {
4304+
"browserTarget": "pipe-demo:build"
4305+
},
4306+
"configurations": {
4307+
"production": {
4308+
"browserTarget": "pipe-demo:build:production"
4309+
}
4310+
}
4311+
},
4312+
"extract-i18n": {
4313+
"builder": "@angular-devkit/build-angular:extract-i18n",
4314+
"options": {
4315+
"browserTarget": "pipe-demo:build"
4316+
}
4317+
},
4318+
"test": {
4319+
"builder": "@angular-devkit/build-angular:karma",
4320+
"options": {
4321+
"main": "steps/pipe-demo/src/test.ts",
4322+
"polyfills": "steps/pipe-demo/src/polyfills.ts",
4323+
"tsConfig": "steps/pipe-demo/tsconfig.spec.json",
4324+
"karmaConfig": "steps/pipe-demo/karma.conf.js",
4325+
"styles": [
4326+
"steps/pipe-demo/src/styles.css"
4327+
],
4328+
"scripts": [],
4329+
"assets": [
4330+
"steps/pipe-demo/src/favicon.ico",
4331+
"steps/pipe-demo/src/assets"
4332+
]
4333+
}
4334+
},
4335+
"lint": {
4336+
"builder": "@angular-devkit/build-angular:tslint",
4337+
"options": {
4338+
"tsConfig": [
4339+
"steps/pipe-demo/tsconfig.app.json",
4340+
"steps/pipe-demo/tsconfig.spec.json"
4341+
],
4342+
"exclude": [
4343+
"**/node_modules/**"
4344+
]
4345+
}
4346+
}
4347+
}
42494348
}
42504349
},
42514350
"defaultProject": "angular-200",

‎steps/pipe-demo/browserslist

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
#
5+
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
6+
7+
> 0.5%
8+
last 2 versions
9+
Firefox ESR
10+
not dead
11+
not IE 9-11
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { MyPipePipe } from './my-pipe.pipe';
3+
4+
@Component({
5+
selector: 'sfeir-root',
6+
template: `
7+
<div>Hello World!</div>
8+
<div>{{ 4 | myPipe }} + {{ num }} + {{ num2 }}</div>
9+
`,
10+
styles: []
11+
})
12+
export class AppComponent implements OnInit {
13+
title = 'pipe-demo';
14+
num: number;
15+
num2: number;
16+
17+
constructor(private pipe: MyPipePipe) {}
18+
19+
ngOnInit() {
20+
this.num = this.pipe.transform(10);
21+
this.pipe.leeeeeek = 30000;
22+
this.num2 = this.pipe.transform(10, 20);
23+
}
24+
}

‎steps/pipe-demo/src/app/app.module.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
4+
import { AppComponent } from './app.component';
5+
import { MyPipePipe } from './my-pipe.pipe';
6+
7+
@NgModule({
8+
declarations: [AppComponent, MyPipePipe],
9+
imports: [BrowserModule],
10+
providers: [MyPipePipe],
11+
bootstrap: [AppComponent]
12+
})
13+
export class AppModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { MyPipePipe } from './my-pipe.pipe';
2+
3+
describe('MyPipePipe', () => {
4+
it('create an instance', () => {
5+
const pipe = new MyPipePipe();
6+
expect(pipe).toBeTruthy();
7+
});
8+
});
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
3+
@Pipe({
4+
name: 'myPipe'
5+
})
6+
export class MyPipePipe implements PipeTransform {
7+
public leeeeeek = 10;
8+
9+
transform(value: number, mult = 10) {
10+
// DON'T DO THIS !!!!!
11+
// return value * leek;
12+
return value * mult;
13+
}
14+
}

‎steps/pipe-demo/src/assets/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file can be replaced during build by using the `fileReplacements` array.
2+
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3+
// The list of file replacements can be found in `angular.json`.
4+
5+
export const environment = {
6+
production: false
7+
};
8+
9+
/*
10+
* For easier debugging in development mode, you can import the following file
11+
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12+
*
13+
* This import should be commented out in production mode because it will have a negative impact
14+
* on performance if an error is thrown.
15+
*/
16+
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

‎steps/pipe-demo/src/favicon.ico

5.3 KB
Binary file not shown.

‎steps/pipe-demo/src/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>PipeDemo</title>
6+
<base href="/" />
7+
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
10+
</head>
11+
<body>
12+
<sfeir-root></sfeir-root>
13+
</body>
14+
</html>

‎steps/pipe-demo/src/main.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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()
12+
.bootstrapModule(AppModule)
13+
.catch(err => console.error(err));

‎steps/pipe-demo/src/polyfills.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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/guide/browser-support
15+
*/
16+
17+
/***************************************************************************************************
18+
* BROWSER POLYFILLS
19+
*/
20+
21+
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
22+
// import 'core-js/es6/symbol';
23+
// import 'core-js/es6/object';
24+
// import 'core-js/es6/function';
25+
// import 'core-js/es6/parse-int';
26+
// import 'core-js/es6/parse-float';
27+
// import 'core-js/es6/number';
28+
// import 'core-js/es6/math';
29+
// import 'core-js/es6/string';
30+
// import 'core-js/es6/date';
31+
// import 'core-js/es6/array';
32+
// import 'core-js/es6/regexp';
33+
// import 'core-js/es6/map';
34+
// import 'core-js/es6/weak-map';
35+
// import 'core-js/es6/set';
36+
37+
/**
38+
* If the application will be indexed by Google Search, the following is required.
39+
* Googlebot uses a renderer based on Chrome 41.
40+
* https://developers.google.com/search/docs/guides/rendering
41+
**/
42+
// import 'core-js/es6/array';
43+
44+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
45+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
46+
47+
/** IE10 and IE11 requires the following for the Reflect API. */
48+
// import 'core-js/es6/reflect';
49+
50+
/**
51+
* Web Animations `@angular/platform-browser/animations`
52+
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
53+
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
54+
**/
55+
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
56+
57+
/**
58+
* By default, zone.js will patch all possible macroTask and DomEvents
59+
* user can disable parts of macroTask/DomEvents patch by setting following flags
60+
*/
61+
62+
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
63+
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
64+
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
65+
66+
/*
67+
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
68+
* with the following flag, it will bypass `zone.js` patch for IE/Edge
69+
*/
70+
// (window as any).__Zone_enable_cross_context_check = true;
71+
72+
/***************************************************************************************************
73+
* Zone JS is required by default for Angular itself.
74+
*/
75+
import 'zone.js/dist/zone'; // Included with Angular CLI.
76+
77+
/***************************************************************************************************
78+
* APPLICATION IMPORTS
79+
*/

‎steps/pipe-demo/src/styles.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* You can add global styles to this file, and also import other style files */

‎steps/pipe-demo/tsconfig.app.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../out-tsc/app",
5+
"types": []
6+
},
7+
"exclude": ["test.ts", "**/*.spec.ts"]
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.