Skip to content

Commit e021ae7

Browse files
minor application tweaks
1 parent 6c66b9f commit e021ae7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

app/app.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ angular.module('app', ['ngComponentRouter', 'dialog', 'heroes', 'crisis-center']
88
$rootRouter.config([
99
{ path: '/...', name: 'App', component: 'app', useAsDefault: true }
1010
]);
11-
$rootRouter.navigate(['App']);
1211
})
1312

1413
.component('app', {
@@ -21,6 +20,6 @@ angular.module('app', ['ngComponentRouter', 'dialog', 'heroes', 'crisis-center']
2120
$routeConfig: [
2221
{path: '/crisis-center/...', name: 'CrisisCenter', component: 'crisisCenter', useAsDefault: true},
2322
{path: '/heroes/...', name: 'Heroes', component: 'heroes'},
24-
{path: '/disaster', name: 'Asteroid', redirectTo: ['CrisisCenter', 'CrisisDetail', {id:3}]}
23+
// {path: '/disaster', name: 'Asteroid', redirectTo: ['CrisisCenter', 'CrisisDetail', {id:3}]}
2524
]
2625
});

app/heroes.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ angular.module('heroes', [])
1313

1414
.component('heroList', {
1515
template:
16-
'<div ng-repeat="hero in $ctrl.heroes">\n' +
16+
'<div ng-repeat="hero in $ctrl.heroes" ' +
17+
' ng-class="{ selected: $ctrl.isSelected(hero) }">\n' +
1718
'<a ng-link="[\'HeroDetail\', {id: hero.id}]">{{hero.name}}</a>\n' +
1819
'</div>',
1920
controller: HeroListComponent
@@ -61,33 +62,29 @@ function HeroService($q) {
6162

6263
function HeroListComponent(heroService) {
6364
var _selectedId = null;
64-
var ctrl = this;
65+
var $ctrl = this;
6566

6667
this.$routerOnActivate = function(next) {
6768
// Load up the heroes for this view
6869
heroService.getHeroes().then(function(heroes) {
69-
ctrl.heroes = heroes;
70+
$ctrl.heroes = heroes;
7071
_selectedId = next.params.id;
7172
});
7273
};
7374

7475
this.isSelected = function(hero) {
7576
return (hero.id == _selectedId);
7677
};
77-
78-
this.onSelect = function(hero) {
79-
this.$router.navigate(['HeroDetail', { id: hero.id }]);
80-
};
8178
}
8279

8380
function HeroDetailComponent(heroService) {
84-
var ctrl = this;
81+
var $ctrl = this;
8582

8683
this.$routerOnActivate = function(next) {
8784
// Get the hero identified by the route parameter
8885
var id = next.params.id;
8986
heroService.getHero(id).then(function(hero) {
90-
ctrl.hero = hero;
87+
$ctrl.hero = hero;
9188
});
9289
};
9390

0 commit comments

Comments
 (0)