Skip to content

Commit 2559413

Browse files
committed
Updated Angular2 to RC5
1 parent 2cd336d commit 2559413

File tree

25 files changed

+5988
-301
lines changed

25 files changed

+5988
-301
lines changed

client/app/app.component.ts

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
1-
import {Component} from 'angular2/core';
2-
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
3-
import {HeroesComponent} from './components/heroes/heroes.component';
4-
import {HeroService} from "./services/hero.service";
5-
import {DashboardComponent} from "./components/dashboard/dashboard.component";
6-
import {HeroDetailComponent} from "./components/heroDetail/hero-detail.component";
1+
import {Component} from '@angular/core';
2+
3+
// import {HeroesComponent} from './components/heroes/heroes.component';
4+
// import {HeroService} from "./services/hero.service";
5+
// import {DashboardComponent} from "./components/dashboard/dashboard.component";
6+
// import {HeroDetailComponent} from "./components/heroDetail/hero-detail.component";
77

88
@Component({
99
selector:'my-app',
10-
templateUrl:'./app/app.html',
11-
directives:[ROUTER_DIRECTIVES],
12-
providers: [
13-
ROUTER_PROVIDERS,
14-
HeroService
15-
]
10+
template: '<h1>Angular2 updated to RC5</h1>'
1611
})
1712

18-
@RouteConfig([
19-
{
20-
path: '/heroes',
21-
name: 'Heroes',
22-
component: HeroesComponent
23-
},
24-
{
25-
path: '/dashboard',
26-
name: 'Dashboard',
27-
component: DashboardComponent,
28-
useAsDefault: true
29-
},
30-
{
31-
path: '/detail/:id',
32-
name: 'HeroDetail',
33-
component: HeroDetailComponent
34-
}
35-
])
36-
3713
export class AppComponent {
3814
title = 'Tour of Heroes';
3915
}

client/app/app.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<h1>{{title}}</h1>
1+
<!--<h1>{{title}}</h1>
22
<nav>
33
<a [routerLink]="['Dashboard']">Dashboard</a>
44
<a [routerLink]="['Heroes']">Heroes</a>
55
</nav>
6-
<router-outlet></router-outlet>
6+
<router-outlet></router-outlet>-->

client/app/app.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { AppComponent } from './app.component';
4+
5+
@NgModule({
6+
imports: [ BrowserModule ],
7+
declarations: [ AppComponent ],
8+
bootstrap: [ AppComponent ]
9+
})
10+
export class AppModule { }
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
/**
2-
* Created by Moiz.Kachwala on 02-06-2016.
3-
*/
1+
// /**
2+
// * Created by Moiz.Kachwala on 02-06-2016.
3+
// */
44

5-
import {Component, OnInit} from 'angular2/core';
6-
import {Hero} from "../../models/hero";
7-
import {HeroService} from "../../services/hero.service";
8-
import { Router } from 'angular2/router';
5+
// import {Component, OnInit} from 'angular2/core';
6+
// import {Hero} from "../../models/hero";
7+
// import {HeroService} from "../../services/hero.service";
8+
// import { Router } from 'angular2/router';
99

10-
@Component({
11-
selector: 'my-dashboard',
12-
templateUrl: './app/components/dashboard/dashboard.component.html',
13-
styleUrls:['./app/components/dashboard/dashboard.component.css']
14-
})
10+
// @Component({
11+
// selector: 'my-dashboard',
12+
// templateUrl: './app/components/dashboard/dashboard.component.html',
13+
// styleUrls:['./app/components/dashboard/dashboard.component.css']
14+
// })
1515

16-
export class DashboardComponent implements OnInit {
17-
heroes: Hero[] = [];
16+
// export class DashboardComponent implements OnInit {
17+
// heroes: Hero[] = [];
1818

19-
constructor(
20-
private router: Router,
21-
private heroService: HeroService) {
22-
}
19+
// constructor(
20+
// private router: Router,
21+
// private heroService: HeroService) {
22+
// }
2323

24-
ngOnInit() {
25-
this.heroService.getHeroes()
26-
.then(heroes => this.heroes = heroes);
27-
}
24+
// ngOnInit() {
25+
// this.heroService.getHeroes()
26+
// .then(heroes => this.heroes = heroes);
27+
// }
2828

29-
gotoDetail(hero: Hero) {
30-
let link = ['HeroDetail', { id: hero._id }];
31-
this.router.navigate(link);
32-
}
33-
}
29+
// gotoDetail(hero: Hero) {
30+
// let link = ['HeroDetail', { id: hero._id }];
31+
// this.router.navigate(link);
32+
// }
33+
// }
Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
/**
2-
* Created by Moiz.Kachwala on 02-06-2016.
3-
*/
4-
5-
import {Component, Input, OnInit} from 'angular2/core';
6-
import {Hero} from "../../models/hero";
7-
import { RouteParams } from 'angular2/router';
8-
import {HeroService} from "../../services/hero.service";
9-
10-
@Component({
11-
selector: 'my-hero-detail',
12-
templateUrl:'./app/components/heroDetail/hero-detail.component.html',
13-
styleUrls:['./app/components/heroDetail/hero-detail.component.css']
14-
})
15-
16-
export class HeroDetailComponent implements OnInit {
17-
@Input() hero: Hero;
18-
newHero = false;
19-
error: any;
20-
navigated = false; // true if navigated here
21-
22-
23-
constructor(
24-
private heroService: HeroService,
25-
private routeParams: RouteParams) {
26-
}
27-
28-
ngOnInit() {
29-
let id = this.routeParams.get('id');
30-
if (id === 'new') {
31-
this.newHero = true;
32-
this.hero = new Hero();
33-
}else {
34-
this.newHero = false;
35-
this.heroService.getHero(id)
36-
.then(hero => this.hero = hero);
37-
}
38-
}
39-
40-
save() {
41-
this.heroService
42-
.save(this.hero)
43-
.then(hero => {
44-
this.hero = hero; // saved hero, w/ id if new
45-
this.goBack();
46-
})
47-
.catch(error => this.error = error); // TODO: Display error message
48-
}
49-
50-
goBack() {
51-
window.history.back();
52-
}
53-
}
1+
// /**
2+
// * Created by Moiz.Kachwala on 02-06-2016.
3+
// */
4+
5+
// import {Component, Input, OnInit} from 'angular2/core';
6+
// import {Hero} from "../../models/hero";
7+
// import { RouteParams } from 'angular2/router';
8+
// import {HeroService} from "../../services/hero.service";
9+
10+
// @Component({
11+
// selector: 'my-hero-detail',
12+
// templateUrl:'./app/components/heroDetail/hero-detail.component.html',
13+
// styleUrls:['./app/components/heroDetail/hero-detail.component.css']
14+
// })
15+
16+
// export class HeroDetailComponent implements OnInit {
17+
// @Input() hero: Hero;
18+
// newHero = false;
19+
// error: any;
20+
// navigated = false; // true if navigated here
21+
22+
23+
// constructor(
24+
// private heroService: HeroService,
25+
// private routeParams: RouteParams) {
26+
// }
27+
28+
// ngOnInit() {
29+
// let id = this.routeParams.get('id');
30+
// if (id === 'new') {
31+
// this.newHero = true;
32+
// this.hero = new Hero();
33+
// }else {
34+
// this.newHero = false;
35+
// this.heroService.getHero(id)
36+
// .then(hero => this.hero = hero);
37+
// }
38+
// }
39+
40+
// save() {
41+
// this.heroService
42+
// .save(this.hero)
43+
// .then(hero => {
44+
// this.hero = hero; // saved hero, w/ id if new
45+
// this.goBack();
46+
// })
47+
// .catch(error => this.error = error); // TODO: Display error message
48+
// }
49+
50+
// goBack() {
51+
// window.history.back();
52+
// }
53+
// }
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
/**
2-
* Created by Moiz.Kachwala on 02-06-2016.
3-
*/
4-
import {Component, OnInit} from 'angular2/core';
5-
import {HeroService} from "../../services/hero.service";
6-
import {Hero} from "../../models/hero";
7-
import {HeroDetailComponent} from "../heroDetail/hero-detail.component";
8-
import { Router } from 'angular2/router';
1+
// /**
2+
// * Created by Moiz.Kachwala on 02-06-2016.
3+
// */
4+
// import {Component, OnInit} from 'angular2/core';
5+
// import {HeroService} from "../../services/hero.service";
6+
// import {Hero} from "../../models/hero";
7+
// import {HeroDetailComponent} from "../heroDetail/hero-detail.component";
8+
// import { Router } from 'angular2/router';
99

10-
@Component({
11-
selector: 'my-heroes',
12-
templateUrl: './app/components/heroes/heroes.component.html',
13-
styleUrls: ['./app/components/heroes/heroes.component.css'],
14-
providers:[HeroService],
15-
directives:[HeroDetailComponent]
16-
})
10+
// @Component({
11+
// selector: 'my-heroes',
12+
// templateUrl: './app/components/heroes/heroes.component.html',
13+
// styleUrls: ['./app/components/heroes/heroes.component.css'],
14+
// providers:[HeroService],
15+
// directives:[HeroDetailComponent]
16+
// })
1717

18-
export class HeroesComponent implements OnInit {
18+
// export class HeroesComponent implements OnInit {
1919

20-
heroes: Hero[];
21-
selectedHero: Hero;
22-
error: any;
20+
// heroes: Hero[];
21+
// selectedHero: Hero;
22+
// error: any;
2323

24-
constructor(
25-
private router: Router,
26-
private heroService: HeroService) { }
27-
getHeroes() {
28-
this.heroService.getHeroes().then(heroes => this.heroes = heroes);
29-
}
30-
ngOnInit() {
31-
this.getHeroes();
32-
}
33-
onSelect(hero: Hero) { this.selectedHero = hero; }
24+
// constructor(
25+
// private router: Router,
26+
// private heroService: HeroService) { }
27+
// getHeroes() {
28+
// this.heroService.getHeroes().then(heroes => this.heroes = heroes);
29+
// }
30+
// ngOnInit() {
31+
// this.getHeroes();
32+
// }
33+
// onSelect(hero: Hero) { this.selectedHero = hero; }
3434

35-
gotoDetail() {
36-
this.router.navigate(['HeroDetail', { id: this.selectedHero._id }]);
37-
}
35+
// gotoDetail() {
36+
// this.router.navigate(['HeroDetail', { id: this.selectedHero._id }]);
37+
// }
3838

39-
addHero() {
40-
this.selectedHero = null;
41-
this.router.navigate(['HeroDetail', { id: 'new' }]);
42-
}
39+
// addHero() {
40+
// this.selectedHero = null;
41+
// this.router.navigate(['HeroDetail', { id: 'new' }]);
42+
// }
4343

44-
deleteHero(hero: Hero, event: any) {
45-
event.stopPropagation();
46-
this.heroService
47-
.delete(hero)
48-
.then(res => {
49-
this.heroes = this.heroes.filter(h => h !== hero);
50-
if (this.selectedHero === hero) { this.selectedHero = null; }
51-
})
52-
.catch(error => this.error = error);
53-
}
54-
}
44+
// deleteHero(hero: Hero, event: any) {
45+
// event.stopPropagation();
46+
// this.heroService
47+
// .delete(hero)
48+
// .then(res => {
49+
// this.heroes = this.heroes.filter(h => h !== hero);
50+
// if (this.selectedHero === hero) { this.selectedHero = null; }
51+
// })
52+
// .catch(error => this.error = error);
53+
// }
54+
// }

client/app/main.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/* Avoid: 'error TS2304: Cannot find name <type>' during compilation */
22
///<reference path="../typings/globals/es6-shim/index.d.ts"/>
33

4-
import {bootstrap} from 'angular2/platform/browser';
5-
import { HTTP_PROVIDERS } from 'angular2/http';
6-
7-
8-
import {AppComponent} from './app.component';
9-
10-
11-
bootstrap(AppComponent, [HTTP_PROVIDERS]);
4+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
5+
import { AppModule } from './app.module';
6+
platformBrowserDynamic().bootstrapModule(AppModule);

0 commit comments

Comments
 (0)