Skip to content

Commit 822d121

Browse files
committed
answers + more examples
1 parent b6720fa commit 822d121

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+10690
-12
lines changed

1-viewcontent/viewcontent/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1-viewcontent/viewcontent/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"@angular/cli": "~8.0.3",
2929
"@angular/compiler-cli": "~8.0.1",
3030
"@angular/language-service": "~8.0.1",
31-
"@types/node": "~8.9.4",
3231
"@types/jasmine": "~3.3.8",
3332
"@types/jasminewd2": "~2.0.3",
34-
"codelyzer": "^5.0.0",
33+
"@types/node": "~8.9.4",
34+
"codelyzer": "^5.2.0",
3535
"jasmine-core": "~3.4.0",
3636
"jasmine-spec-reporter": "~4.2.1",
3737
"karma": "~4.1.0",

1-viewcontent/viewcontent/src/app/app.component.html

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
<app-item>
12

2-
{{ 'Hello Everyone!' | reverse }}
3+
<ng-template #t>
4+
5+
<div>Some text</div>
6+
7+
</ng-template>
8+
9+
10+
</app-item>
11+
12+
13+
<!-- {{ 'Hello Everyone!' | reverse }} -->
314

415
<!-- {{ 'HELLO' | translate }} -->
516
<!-- DATA TIME -->

1-viewcontent/viewcontent/src/app/item/item.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Banner2Component } from '../banner2/banner2.component';
66

77
@Component({
88
selector: 'app-item',
9-
template: `VIEW | <ng-content select="h1"></ng-content>
9+
template: `VIEW | <ng-template select="h1"></ng-template>
1010
<ng-container *ngTemplateOutlet="mainTemaplte"></ng-container>
1111
1212
@@ -49,6 +49,7 @@ export class ItemComponent implements OnInit, AfterContentInit, AfterViewInit {
4949

5050
ngAfterViewInit() {
5151
console.log('ngAfterViewInit');
52+
console.log('---', this.mainTemaplte);
5253
}
5354

5455
}

2-di/di-tree/.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see https://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

2-di/di-tree/.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events.json
15+
speed-measure-plugin.json
16+
17+
# IDEs and editors
18+
/.idea
19+
.project
20+
.classpath
21+
.c9/
22+
*.launch
23+
.settings/
24+
*.sublime-workspace
25+
26+
# IDE - VSCode
27+
.vscode/*
28+
!.vscode/settings.json
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
.history/*
33+
34+
# misc
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db

2-di/di-tree/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# DiTree
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0.3.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

2-di/di-tree/angular.json

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"di-tree": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "dist/di-tree",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": "src/polyfills.ts",
20+
"tsConfig": "tsconfig.app.json",
21+
"aot": false,
22+
"assets": [
23+
"src/favicon.ico",
24+
"src/assets"
25+
],
26+
"styles": [
27+
"src/styles.css"
28+
],
29+
"scripts": []
30+
},
31+
"configurations": {
32+
"production": {
33+
"fileReplacements": [
34+
{
35+
"replace": "src/environments/environment.ts",
36+
"with": "src/environments/environment.prod.ts"
37+
}
38+
],
39+
"optimization": true,
40+
"outputHashing": "all",
41+
"sourceMap": false,
42+
"extractCss": true,
43+
"namedChunks": false,
44+
"aot": true,
45+
"extractLicenses": true,
46+
"vendorChunk": false,
47+
"buildOptimizer": true,
48+
"budgets": [
49+
{
50+
"type": "initial",
51+
"maximumWarning": "2mb",
52+
"maximumError": "5mb"
53+
}
54+
]
55+
}
56+
}
57+
},
58+
"serve": {
59+
"builder": "@angular-devkit/build-angular:dev-server",
60+
"options": {
61+
"browserTarget": "di-tree:build"
62+
},
63+
"configurations": {
64+
"production": {
65+
"browserTarget": "di-tree:build:production"
66+
}
67+
}
68+
},
69+
"extract-i18n": {
70+
"builder": "@angular-devkit/build-angular:extract-i18n",
71+
"options": {
72+
"browserTarget": "di-tree:build"
73+
}
74+
},
75+
"test": {
76+
"builder": "@angular-devkit/build-angular:karma",
77+
"options": {
78+
"main": "src/test.ts",
79+
"polyfills": "src/polyfills.ts",
80+
"tsConfig": "tsconfig.spec.json",
81+
"karmaConfig": "karma.conf.js",
82+
"assets": [
83+
"src/favicon.ico",
84+
"src/assets"
85+
],
86+
"styles": [
87+
"src/styles.css"
88+
],
89+
"scripts": []
90+
}
91+
},
92+
"lint": {
93+
"builder": "@angular-devkit/build-angular:tslint",
94+
"options": {
95+
"tsConfig": [
96+
"tsconfig.app.json",
97+
"tsconfig.spec.json",
98+
"e2e/tsconfig.json"
99+
],
100+
"exclude": [
101+
"**/node_modules/**"
102+
]
103+
}
104+
},
105+
"e2e": {
106+
"builder": "@angular-devkit/build-angular:protractor",
107+
"options": {
108+
"protractorConfig": "e2e/protractor.conf.js",
109+
"devServerTarget": "di-tree:serve"
110+
},
111+
"configurations": {
112+
"production": {
113+
"devServerTarget": "di-tree:serve:production"
114+
}
115+
}
116+
}
117+
}
118+
}},
119+
"defaultProject": "di-tree"
120+
}

2-di/di-tree/browserslist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

2-di/di-tree/e2e/protractor.conf.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter } = require('jasmine-spec-reporter');
6+
7+
/**
8+
* @type { import("protractor").Config }
9+
*/
10+
exports.config = {
11+
allScriptsTimeout: 11000,
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
15+
capabilities: {
16+
'browserName': 'chrome'
17+
},
18+
directConnect: true,
19+
baseUrl: 'http://localhost:4200/',
20+
framework: 'jasmine',
21+
jasmineNodeOpts: {
22+
showColors: true,
23+
defaultTimeoutInterval: 30000,
24+
print: function() {}
25+
},
26+
onPrepare() {
27+
require('ts-node').register({
28+
project: require('path').join(__dirname, './tsconfig.json')
29+
});
30+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31+
}
32+
};

2-di/di-tree/e2e/src/app.e2e-spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { AppPage } from './app.po';
2+
import { browser, logging } from 'protractor';
3+
4+
describe('workspace-project App', () => {
5+
let page: AppPage;
6+
7+
beforeEach(() => {
8+
page = new AppPage();
9+
});
10+
11+
it('should display welcome message', () => {
12+
page.navigateTo();
13+
expect(page.getTitleText()).toEqual('Welcome to di-tree!');
14+
});
15+
16+
afterEach(async () => {
17+
// Assert that there are no errors emitted from the browser
18+
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19+
expect(logs).not.toContain(jasmine.objectContaining({
20+
level: logging.Level.SEVERE,
21+
} as logging.Entry));
22+
});
23+
});

2-di/di-tree/e2e/src/app.po.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { browser, by, element } from 'protractor';
2+
3+
export class AppPage {
4+
navigateTo() {
5+
return browser.get(browser.baseUrl) as Promise<any>;
6+
}
7+
8+
getTitleText() {
9+
return element(by.css('app-root h1')).getText() as Promise<string>;
10+
}
11+
}

2-di/di-tree/e2e/tsconfig.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/e2e",
5+
"module": "commonjs",
6+
"target": "es5",
7+
"types": [
8+
"jasmine",
9+
"jasminewd2",
10+
"node"
11+
]
12+
}
13+
}

0 commit comments

Comments
 (0)