Skip to content

Commit 36a7e58

Browse files
committed
feat(no hero): my first if else with Angular :)
1 parent 805f4db commit 36a7e58

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/app/heroes/hero-detail/hero-detail.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="container">
2-
<div *ngIf="hero">
2+
<div *ngIf="hero; else noHero">
33
<h2>{{hero.name}} {{ 'details' | translate }}!</h2>
44
<div class="input-group">
55
<span class="input-group-addon" id="hero-id">Id</span>
@@ -22,4 +22,7 @@ <h2>{{hero.name}} {{ 'details' | translate }}!</h2>
2222
<button class="btn btn-secondary" (click)="goBack()">{{ 'back' | translate }}</button>
2323
<button class="btn btn-primary" (click)="saveHero()">{{ 'saveHero' | translate }}</button>
2424
</div>
25+
<ng-template #noHero>
26+
<p>{{'noHero' | translate}}</p>
27+
</ng-template>
2528
</div>

src/app/heroes/shared/hero.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class HeroService {
1212
private heroesUrl;
1313

1414
private static handleError(error: any): Promise<any> {
15-
window.alert(error._body);
1615
return Promise.reject(error.message || error);
1716
}
1817

src/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"cancel": "Cancel",
2727
"remove": "Remove",
2828
"findHero": "Find a hero",
29-
"back": "Back"
29+
"back": "Back",
30+
"noHero": "There is no hero!"
3031
}

src/assets/i18n/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"cancel": "Cancelar",
2727
"remove": "Eliminar",
2828
"findHero": "Busca un heroe",
29-
"back": "Atras"
29+
"back": "Atras",
30+
"noHero": "No hay heroe!"
3031
}

0 commit comments

Comments
 (0)