Skip to content

Commit a0722a9

Browse files
author
Renante D. Entera
committed
Course Project: Lazy loading and environment variables
1 parent 0092c23 commit a0722a9

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
import { NgModule } from "@angular/core";
2-
import { Routes, RouterModule } from "@angular/router";
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
33

44
const appRoutes: Routes = [
5-
{ path: "", redirectTo: "/recipes", pathMatch: "full" },
5+
{ path: '', redirectTo: '/recipes', pathMatch: 'full' },
66
{
7-
path: "recipes",
8-
loadChildren: () =>
9-
import("./recipes/recipes.module").then(m => m.RecipesModule)
7+
path: 'auth',
8+
loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule)
109
},
11-
{
12-
path: "shopping-list",
13-
loadChildren: () =>
14-
import("./shopping-list/shopping-list.module").then(
15-
m => m.ShoppingListModule
16-
)
10+
{
11+
path: 'recipes',
12+
loadChildren: () => import('./recipes/recipes.module').then(m => m.RecipesModule)
1713
},
18-
{
19-
path: "auth",
20-
loadChildren: () => import("./auth/auth.module").then(m => m.AuthModule)
14+
{
15+
path: 'shopping-list',
16+
loadChildren: () => import('./shopping-list/shopping-list.module').then(m => m.ShoppingListModule)
2117
}
2218
];
2319

2420
@NgModule({
25-
imports: [RouterModule.forRoot(appRoutes)],
21+
imports: [
22+
RouterModule.forRoot(appRoutes, { preloadingStrategy: PreloadAllModules })
23+
],
2624
exports: [RouterModule]
2725
})
2826
export class AppRoutingModule {}

course-project/src/app/auth/auth.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HttpClient, HttpErrorResponse } from '@angular/common/http';
33
import { Router } from '@angular/router';
44
import { catchError, tap } from 'rxjs/operators';
55
import { throwError, BehaviorSubject } from 'rxjs';
6+
import { environment } from '../../environments/environment';
67

78
import { User } from './user.model';
89

@@ -26,7 +27,7 @@ export class AuthService {
2627
signup(email: string, password: string) {
2728
return this.http
2829
.post<AuthResponseData>(
29-
'https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyDKcrz9ecyL7uH_fOrwtTunwEHikHmVwfM',
30+
'https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=' + environment.firebaseAPIKey,
3031
{
3132
email: email,
3233
password: password,
@@ -49,7 +50,7 @@ export class AuthService {
4950
login(email: string, password: string) {
5051
return this.http
5152
.post<AuthResponseData>(
52-
'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyDKcrz9ecyL7uH_fOrwtTunwEHikHmVwfM',
53+
'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + environment.firebaseAPIKey,
5354
{
5455
email: email,
5556
password: password,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
2-
production: true
2+
production: true,
3+
firebaseAPIKey: 'AIzaSyDKcrz9ecyL7uH_fOrwtTunwEHikHmVwfM'
34
};

course-project/src/environments/environment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// The list of file replacements can be found in `angular.json`.
44

55
export const environment = {
6-
production: false
6+
production: false,
7+
firebaseAPIKey: 'AIzaSyDKcrz9ecyL7uH_fOrwtTunwEHikHmVwfM'
78
};
89

910
/*

0 commit comments

Comments
 (0)