Skip to content

Commit

Permalink
Load city from url
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyoconnor committed May 23, 2018
1 parent 375b20f commit 1bda146
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/city/city.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { WeatherService } from '../weather.service';
import { ActivatedRoute } from '@angular/router';

@Component({
selector: 'app-city',
Expand All @@ -8,16 +9,18 @@ import { WeatherService } from '../weather.service';
})
export class CityComponent implements OnInit {

city = 'Vancouver';
city = '?';
weather = '?';
temp = 0;
failedToLoad: boolean;

constructor(public weatherService: WeatherService) {
constructor(public weatherService: WeatherService, private route: ActivatedRoute) {

}

ngOnInit() {
this.city = this.route.snapshot.params['city'];

this.weatherService.getCurrentWeather(this.city).subscribe(x => {
this.weather = x.weather.description;
this.temp = x.temp;
Expand Down

0 comments on commit 1bda146

Please sign in to comment.