Skip to content

Commit 9575cd8

Browse files
author
Luca Sartori
committed
Week 3-4 exercise added
1 parent 23a619e commit 9575cd8

35 files changed

+713
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ _But as they say... water under the bridge._
430430

431431
`Angular` is a new framework, a new codebase and **A LOT** of new features. The team wanted _so bad_ to emphasize the _new_ part that the ditched the `.js` part of the name (commonly used on Js frameworks) and they adopted [_semver_](http://semver.org/).
432432

433-
The current version is 5.0, but we will focus on version 4.x as this is more mature and stable and most of the features of 5.0 are not difficult to learn after picking up 4.x
433+
The current stable version is 5.0
434434

435435
### Reading:
436436
- [Angular Quickstart](https://angular.io/guide/quickstart)
@@ -485,6 +485,8 @@ You will learn about the fundamentals, the good ways, the more performant and po
485485

486486
### Exercise:
487487

488+
![Show Me What You Got](assets/SMWYG.gif)
489+
488490
[index](#index)
489491

490492
# Week 4: Angular 301 and stuff

assets/SMWYG.gif

1.68 MB
Loading

assets/detailResult.jpg

55.6 KB
Loading

assets/homeResult.jpg

95.7 KB
Loading

assets/nasaDetail.jpg

70.4 KB
Loading

assets/nasaHome.jpg

112 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"project": {
4+
"name": "angular-tour-of-heroes"
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+
"exclude": "**/node_modules/**"
41+
},
42+
{
43+
"project": "src/tsconfig.spec.json",
44+
"exclude": "**/node_modules/**"
45+
},
46+
{
47+
"project": "e2e/tsconfig.e2e.json",
48+
"exclude": "**/node_modules/**"
49+
}
50+
],
51+
"test": {
52+
"karma": {
53+
"config": "./karma.conf.js"
54+
}
55+
},
56+
"defaults": {
57+
"styleExt": "css",
58+
"component": {}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# AngularTourOfHeroes
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.0.
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).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { AppPage } from './app.po';
2+
3+
describe('angular-tour-of-heroes App', () => {
4+
let page: AppPage;
5+
6+
beforeEach(() => {
7+
page = new AppPage();
8+
});
9+
10+
it('should display welcome message', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('Welcome to app!');
13+
});
14+
});
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('/');
6+
}
7+
8+
getParagraphText() {
9+
return element(by.css('app-root h1')).getText();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/e2e",
5+
"baseUrl": "./",
6+
"module": "commonjs",
7+
"target": "es5",
8+
"types": [
9+
"jasmine",
10+
"jasminewd2",
11+
"node"
12+
]
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/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+
coverageIstanbulReporter: {
19+
reports: [ 'html', 'lcovonly' ],
20+
fixWebpackSourcePaths: true
21+
},
22+
angularCli: {
23+
environment: 'dev'
24+
},
25+
reporters: ['progress', 'kjhtml'],
26+
port: 9876,
27+
colors: true,
28+
logLevel: config.LOG_INFO,
29+
autoWatch: true,
30+
browsers: ['Chrome'],
31+
singleRun: false
32+
});
33+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "angular-tour-of-heroes",
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": "^5.0.0",
16+
"@angular/common": "^5.0.0",
17+
"@angular/compiler": "^5.0.0",
18+
"@angular/core": "^5.0.0",
19+
"@angular/forms": "^5.0.0",
20+
"@angular/http": "^5.0.0",
21+
"@angular/platform-browser": "^5.0.0",
22+
"@angular/platform-browser-dynamic": "^5.0.0",
23+
"@angular/router": "^5.0.0",
24+
"core-js": "^2.4.1",
25+
"rxjs": "^5.5.2",
26+
"zone.js": "^0.8.14"
27+
},
28+
"devDependencies": {
29+
"@angular/cli": "1.5.0",
30+
"@angular/compiler-cli": "^5.0.0",
31+
"@angular/language-service": "^5.0.0",
32+
"@types/jasmine": "~2.5.53",
33+
"@types/jasminewd2": "~2.0.2",
34+
"@types/node": "~6.0.60",
35+
"codelyzer": "~3.2.0",
36+
"jasmine-core": "~2.6.2",
37+
"jasmine-spec-reporter": "~4.1.0",
38+
"karma": "~1.7.0",
39+
"karma-chrome-launcher": "~2.1.1",
40+
"karma-cli": "~1.0.1",
41+
"karma-coverage-istanbul-reporter": "^1.2.1",
42+
"karma-jasmine": "~1.1.0",
43+
"karma-jasmine-html-reporter": "^0.2.2",
44+
"protractor": "~5.1.2",
45+
"ts-node": "~3.2.0",
46+
"tslint": "~5.7.0",
47+
"typescript": "~2.4.2"
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
onPrepare() {
23+
require('ts-node').register({
24+
project: 'e2e/tsconfig.e2e.json'
25+
});
26+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27+
}
28+
};

src/week2/angular-tour-of-heroes/src/app/app.component.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--The content below is only a placeholder and can be replaced.-->
2+
<div style="text-align:center">
3+
<h1>
4+
Welcome to {{title}}!
5+
</h1>
6+
<img width="300" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
7+
</div>
8+
<h2>Here are some links to help you start: </h2>
9+
<ul>
10+
<li>
11+
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12+
</li>
13+
<li>
14+
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15+
</li>
16+
<li>
17+
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18+
</li>
19+
</ul>
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { TestBed, async } from '@angular/core/testing';
2+
import { AppComponent } from './app.component';
3+
describe('AppComponent', () => {
4+
beforeEach(async(() => {
5+
TestBed.configureTestingModule({
6+
declarations: [
7+
AppComponent
8+
],
9+
}).compileComponents();
10+
}));
11+
it('should create the app', async(() => {
12+
const fixture = TestBed.createComponent(AppComponent);
13+
const app = fixture.debugElement.componentInstance;
14+
expect(app).toBeTruthy();
15+
}));
16+
it(`should have as title 'app'`, async(() => {
17+
const fixture = TestBed.createComponent(AppComponent);
18+
const app = fixture.debugElement.componentInstance;
19+
expect(app.title).toEqual('app');
20+
}));
21+
it('should render title in a h1 tag', async(() => {
22+
const fixture = TestBed.createComponent(AppComponent);
23+
fixture.detectChanges();
24+
const compiled = fixture.debugElement.nativeElement;
25+
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
26+
}));
27+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-root',
5+
templateUrl: './app.component.html',
6+
styleUrls: ['./app.component.css']
7+
})
8+
export class AppComponent {
9+
title = 'app';
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
4+
5+
import { AppComponent } from './app.component';
6+
7+
8+
@NgModule({
9+
declarations: [
10+
AppComponent
11+
],
12+
imports: [
13+
BrowserModule
14+
],
15+
providers: [],
16+
bootstrap: [AppComponent]
17+
})
18+
export class AppModule { }

src/week2/angular-tour-of-heroes/src/assets/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)