Skip to content

Commit 59fe682

Browse files
committed
Merge branch 'release/1.0.2'
2 parents c966090 + e719d29 commit 59fe682

24 files changed

+521
-118
lines changed

Diff for: .nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.7.3
1+
7.7.4

Diff for: package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-lecture",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"license": "MIT",
55
"author": "Exequiel Ceasar Navarrete <[email protected]>",
66
"scripts": {
@@ -14,24 +14,24 @@
1414
},
1515
"private": true,
1616
"dependencies": {
17-
"@angular/common": ">=4.0.0-beta <5.0.0",
18-
"@angular/compiler": ">=4.0.0-beta <5.0.0",
19-
"@angular/core": ">=4.0.0-beta <5.0.0",
20-
"@angular/forms": ">=4.0.0-beta <5.0.0",
21-
"@angular/http": ">=4.0.0-beta <5.0.0",
17+
"@angular/common": "^4.0.0",
18+
"@angular/compiler": "^4.0.0",
19+
"@angular/core": "^4.0.0",
20+
"@angular/forms": "^4.0.0",
21+
"@angular/http": "^4.0.0",
2222
"@angular/material": "^2.0.0-beta.2",
23-
"@angular/platform-browser": ">=4.0.0-beta <5.0.0",
24-
"@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",
25-
"@angular/router": ">=4.0.0-beta <5.0.0",
23+
"@angular/platform-browser": "^4.0.0",
24+
"@angular/platform-browser-dynamic": "^4.0.0",
25+
"@angular/router": "^4.0.0",
2626
"core-js": "^2.4.1",
2727
"hammerjs": "^2.0.8",
28-
"normalize.css": "^5.0.0",
28+
"normalize.css": "^6.0.0",
2929
"rxjs": "^5.1.0",
30-
"zone.js": "^0.7.6"
30+
"zone.js": "^0.8.5"
3131
},
3232
"devDependencies": {
33-
"@angular/cli": "1.0.0-rc.2",
34-
"@angular/compiler-cli": ">=4.0.0-beta <5.0.0",
33+
"@angular/cli": "^1.0.0",
34+
"@angular/compiler-cli": "^4.0.0",
3535
"@types/jasmine": "2.5.38",
3636
"@types/node": "~6.0.60",
3737
"codelyzer": "~2.0.0",
@@ -46,6 +46,6 @@
4646
"protractor": "~5.1.0",
4747
"ts-node": "~2.0.0",
4848
"tslint": "~4.5.0",
49-
"typescript": "~2.1.0"
49+
"typescript": "^2.2.2"
5050
}
5151
}

Diff for: src/app/app-routing.module.ts

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ const routes: Routes = [
3434
}, {
3535
path: 'two-way-data-binding',
3636
loadChildren: './lecture/two-way-data-binding/two-way-data-binding.module.ts#TwoWayDataBindingModule'
37+
}, {
38+
path: 'pipes',
39+
loadChildren: './lecture/pipes/pipes.module.ts#PipesModule'
40+
}, {
41+
path: 'custom-pipes',
42+
loadChildren: './lecture/custom-pipes/custom-pipes.module.ts#CustomPipesModule'
43+
}, {
44+
path: 'async-pipe',
45+
loadChildren: './lecture/async-pipe/async-pipe.module.ts#AsyncPipeModule'
3746
}
3847
];
3948

Diff for: src/app/app.component.html

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<a [routerLink]="['/inputs']" md-list-item>7. Inputs</a>
2121
<a [routerLink]="['/outputs']" md-list-item>8. Outputs</a>
2222
<a [routerLink]="['/two-way-data-binding']" md-list-item>9. Two-way Data Binding</a>
23+
<a [routerLink]="['/pipes']" md-list-item>10.1 Pipes</a>
24+
<a [routerLink]="['/custom-pipes']" md-list-item>10.2 Custom Pipes</a>
25+
<a [routerLink]="['/async-pipe/promises']" md-list-item>10.3.1 Promises</a>
26+
<a [routerLink]="['/async-pipe/observables']" md-list-item>10.3.2 Observables</a>
27+
<a [routerLink]="['/async-pipe']" md-list-item>10.3.3 Async Pipe</a>
2328
</md-nav-list>
2429
</md-sidenav>
2530

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
import { IndexComponent } from './index/index.component';
5+
import { PromisesComponent } from './promises/promises.component';
6+
import { ObservablesComponent } from './observables/observables.component';
7+
8+
const routes: Routes = [
9+
{
10+
path: '',
11+
component: IndexComponent
12+
}, {
13+
path: 'promises',
14+
component: PromisesComponent
15+
}, {
16+
path: 'observables',
17+
component: ObservablesComponent
18+
}
19+
];
20+
21+
@NgModule({
22+
imports: [RouterModule.forChild(routes)],
23+
exports: [RouterModule]
24+
})
25+
export class AsyncPipeRoutingModule { }

Diff for: src/app/lecture/async-pipe/async-pipe.module.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
4+
import { AsyncPipeRoutingModule } from './async-pipe-routing.module';
5+
import { IndexComponent } from './index/index.component';
6+
import { PromisesComponent } from './promises/promises.component';
7+
import { ObservablesComponent } from './observables/observables.component';
8+
9+
@NgModule({
10+
imports: [
11+
CommonModule,
12+
AsyncPipeRoutingModule
13+
],
14+
declarations: [
15+
IndexComponent,
16+
PromisesComponent,
17+
ObservablesComponent
18+
]
19+
})
20+
export class AsyncPipeModule { }
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { IndexComponent } from './index.component';
4+
5+
describe('IndexComponent', () => {
6+
let component: IndexComponent;
7+
let fixture: ComponentFixture<IndexComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ IndexComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(IndexComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

Diff for: src/app/lecture/async-pipe/index/index.component.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs/Observable';
3+
import 'rxjs/add/operator/delayWhen';
4+
import 'rxjs/add/observable/interval';
5+
import 'rxjs/add/observable/of';
6+
import 'rxjs/add/observable/timer';
7+
8+
@Component({
9+
selector: 'app-index',
10+
template: `
11+
<p>{{ asyncVar1 | async }}</p>
12+
<p>{{ asyncVar2 | async }}</p>
13+
<p>{{ asyncVar3 | async }}</p>
14+
`
15+
})
16+
export class IndexComponent implements OnInit {
17+
public asyncVar1: Promise<string>;
18+
public asyncVar2: Observable<string>;
19+
public asyncVar3: Observable<number>;
20+
21+
constructor() { }
22+
23+
ngOnInit() {
24+
this.asyncVar1 = new Promise((resolve, reject) => {
25+
setTimeout(() => {
26+
resolve('I a am a resolved value of promise!');
27+
}, 3000);
28+
});
29+
30+
this.asyncVar2 = Observable
31+
.of('I am a value from observable')
32+
.delayWhen(() => Observable.timer(5000))
33+
;
34+
35+
// emit values 0-n every n seconds
36+
this.asyncVar3 = Observable.interval(1000);
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ObservablesComponent } from './observables.component';
4+
5+
describe('ObservablesComponent', () => {
6+
let component: ObservablesComponent;
7+
let fixture: ComponentFixture<ObservablesComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ ObservablesComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ObservablesComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs/Observable';
3+
4+
@Component({
5+
selector: 'app-observables',
6+
template: `View the console to see the output`
7+
})
8+
export class ObservablesComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
const obsInstance: Observable<string> = Observable.create((observer) => {
14+
setTimeout(() => {
15+
observer.next('My first message');
16+
}, 2000);
17+
18+
setTimeout(() => {
19+
observer.next('My second message');
20+
}, 3000);
21+
22+
setTimeout(() => {
23+
observer.complete();
24+
}, 5000);
25+
});
26+
27+
obsInstance.subscribe({
28+
next: (message) => console.log(message),
29+
complete: () => console.log('Observable completed')
30+
});
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { PromisesComponent } from './promises.component';
4+
5+
describe('PromisesComponent', () => {
6+
let component: PromisesComponent;
7+
let fixture: ComponentFixture<PromisesComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ PromisesComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(PromisesComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-promises',
5+
template: `View the console to see the output`
6+
})
7+
export class PromisesComponent implements OnInit {
8+
9+
constructor() { }
10+
11+
ngOnInit() {
12+
const timeoutPromise = new Promise((resolve, reject) => {
13+
setTimeout(() => {
14+
resolve('setTimeout() executed');
15+
}, 5000);
16+
});
17+
18+
timeoutPromise.then((message) => console.log(message));
19+
20+
console.log('This will execute before the timeout has been completed.');
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
import { IndexComponent } from './index/index.component';
5+
6+
const routes: Routes = [
7+
{
8+
path: '',
9+
component: IndexComponent,
10+
children: []
11+
}
12+
];
13+
14+
@NgModule({
15+
imports: [RouterModule.forChild(routes)],
16+
exports: [RouterModule]
17+
})
18+
export class CustomPipesRoutingModule { }

Diff for: src/app/lecture/custom-pipes/custom-pipes.module.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
4+
import { CustomPipesRoutingModule } from './custom-pipes-routing.module';
5+
import { ReversePipe } from './reverse.pipe';
6+
import { IndexComponent } from './index/index.component';
7+
8+
@NgModule({
9+
imports: [
10+
CommonModule,
11+
CustomPipesRoutingModule
12+
],
13+
declarations: [
14+
IndexComponent,
15+
ReversePipe
16+
]
17+
})
18+
export class CustomPipesModule { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { IndexComponent } from './index.component';
4+
5+
describe('IndexComponent', () => {
6+
let component: IndexComponent;
7+
let fixture: ComponentFixture<IndexComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ IndexComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(IndexComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-index',
5+
template: `
6+
<p>{{ text }}</p>
7+
<p>{{ text | reverse }}</p>
8+
`
9+
})
10+
export class IndexComponent implements OnInit {
11+
public text = 'I am a text';
12+
13+
constructor() { }
14+
15+
ngOnInit() {
16+
}
17+
18+
}

Diff for: src/app/lecture/custom-pipes/reverse.pipe.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ReversePipe } from './reverse.pipe';
2+
3+
describe('ReversePipe', () => {
4+
it('create an instance', () => {
5+
const pipe = new ReversePipe();
6+
expect(pipe).toBeTruthy();
7+
});
8+
});

0 commit comments

Comments
 (0)