Skip to content

Commit

Permalink
#1 use temporary api
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Mar 25, 2019
1 parent 938b76e commit d999ae9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/event-list/event-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ <h1>Events are:</h1>
<fa-icon [icon]="['fas', 'gift']"></fa-icon>
<fa-icon [icon]="['fas', 'ticket-alt']"></fa-icon>

<li *ngFor="let event of events | async">
<a [routerLink]="['/event', event.key]">go to event</a>
<li *ngFor="let event of events">
<a [routerLink]="['/event', event.shortName]">go to event</a>
<p>{{event | json}}</p>
</li>

11 changes: 9 additions & 2 deletions src/app/event-list/event-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { EventService } from '../shared/event.service';
import { Router } from '@angular/router';

@Component({
selector: 'app-event-list',
Expand All @@ -10,10 +11,16 @@ export class EventListComponent implements OnInit {

events: any;

constructor(private eventService: EventService) { }
constructor(private eventService: EventService, private router: Router) { }

ngOnInit() {
this.events = this.eventService.getEvents();
this.eventService.getEvents().subscribe(res => {
if(res.singleEvent) {
this.router.navigate(['/event', res.eventShortName]);
} else {
this.events = res.events;
}
})
}

}

0 comments on commit d999ae9

Please sign in to comment.