Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load default city in StartupComponent or redirect to add-city if there are none. Removing the test cities from the app component since we don't need them any more.
- Loading branch information
1 parent
8a36561
commit 8e430cb
Showing
6 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
<div class='container'> | ||
<router-outlet></router-outlet> | ||
|
||
<p>Some test cities:</p> | ||
<div> | ||
<a routerLink="/city/vancouver">Vancouver</a> | ||
</div> | ||
<div> | ||
<a routerLink="/city/limerick">Limerick</a> | ||
</div> | ||
<div> | ||
<a routerLink="/city/fakecity">Fake</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { WeatherService } from './weather.service'; | ||
import { CityStorageService } from './city-storage.service'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.less'] | ||
}) | ||
export class AppComponent { | ||
|
||
constructor() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { WeatherService } from './weather.service'; | ||
import { CityStorageService } from './city-storage.service'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
template: ``, // Nothing will show on this component. | ||
}) | ||
export class StartupComponent { | ||
|
||
constructor(private cityStorage: CityStorageService, private router: Router) { | ||
if (this.cityStorage.cities.length === 0) { | ||
this.router.navigate(['/add-city/']); | ||
} else { | ||
const defaultCity = this.cityStorage.cities[0]; | ||
console.log('going to default'); | ||
this.router.navigate(['/city/' + defaultCity]); | ||
} | ||
} | ||
} |