From 268b117350d09468d299c4c1e9f906f4dbee0ab6 Mon Sep 17 00:00:00 2001 From: Justin McLellan Date: Sun, 11 Jun 2023 07:57:35 -0500 Subject: [PATCH] standalone step 3 and all providers in root --- src/app/app-routing.module.ts | 44 ++++++++++-------------- src/app/demo/service/country.service.ts | 2 +- src/app/demo/service/customer.service.ts | 2 +- src/app/demo/service/event.service.ts | 2 +- src/app/demo/service/icon.service.ts | 2 +- src/app/demo/service/node.service.ts | 2 +- src/app/demo/service/photo.service.ts | 2 +- src/app/demo/service/product.service.ts | 2 +- src/main.ts | 27 +++++---------- 9 files changed, 34 insertions(+), 51 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 22f708a..3d52bdd 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,29 +1,21 @@ -import { RouterModule } from '@angular/router'; -import { NgModule } from '@angular/core'; +import { Route } from '@angular/router'; import { NotfoundComponent } from './demo/components/notfound/notfound.component'; import { AppLayoutComponent } from "./layout/app.layout.component"; -@NgModule({ - imports: [ - RouterModule.forRoot([ - { - path: '', component: AppLayoutComponent, - children: [ - { path: '', loadChildren: () => import('./demo/components/dashboard/dashboard.module').then(m => m.DashboardModule) }, - { path: 'uikit', loadChildren: () => import('./demo/components/uikit/uikit.module').then(m => m.UIkitModule) }, - { path: 'utilities', loadChildren: () => import('./demo/components/utilities/utilities.module').then(m => m.UtilitiesModule) }, - { path: 'documentation', loadChildren: () => import('./demo/components/documentation/documentation.module').then(m => m.DocumentationModule) }, - { path: 'blocks', loadChildren: () => import('./demo/components/primeblocks/primeblocks.module').then(m => m.PrimeBlocksModule) }, - { path: 'pages', loadChildren: () => import('./demo/components/pages/pages.module').then(m => m.PagesModule) } - ] - }, - { path: 'auth', loadChildren: () => import('./demo/components/auth/auth.module').then(m => m.AuthModule) }, - { path: 'landing', loadChildren: () => import('./demo/components/landing/landing.module').then(m => m.LandingModule) }, - { path: 'notfound', component: NotfoundComponent }, - { path: '**', redirectTo: '/notfound' }, - ], { scrollPositionRestoration: 'enabled', anchorScrolling: 'enabled', onSameUrlNavigation: 'reload' }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule { -} +export const APP_ROUTES: Route[] = [ + { + path: '', component: AppLayoutComponent, + children: [ + { path: '', loadChildren: () => import('./demo/components/dashboard/dashboard.module').then(m => m.DashboardModule) }, + { path: 'uikit', loadChildren: () => import('./demo/components/uikit/uikit.module').then(m => m.UIkitModule) }, + { path: 'utilities', loadChildren: () => import('./demo/components/utilities/utilities.module').then(m => m.UtilitiesModule) }, + { path: 'documentation', loadChildren: () => import('./demo/components/documentation/documentation.module').then(m => m.DocumentationModule) }, + { path: 'blocks', loadChildren: () => import('./demo/components/primeblocks/primeblocks.module').then(m => m.PrimeBlocksModule) }, + { path: 'pages', loadChildren: () => import('./demo/components/pages/pages.module').then(m => m.PagesModule) } + ] + }, + { path: 'auth', loadChildren: () => import('./demo/components/auth/auth.module').then(m => m.AuthModule) }, + { path: 'landing', loadChildren: () => import('./demo/components/landing/landing.module').then(m => m.LandingModule) }, + { path: 'notfound', component: NotfoundComponent }, + { path: '**', redirectTo: '/notfound' }, +]; diff --git a/src/app/demo/service/country.service.ts b/src/app/demo/service/country.service.ts index dc0af14..9a1c7ff 100644 --- a/src/app/demo/service/country.service.ts +++ b/src/app/demo/service/country.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class CountryService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/customer.service.ts b/src/app/demo/service/customer.service.ts index d8d81df..5f5b277 100644 --- a/src/app/demo/service/customer.service.ts +++ b/src/app/demo/service/customer.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Customer } from '../api/customer'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class CustomerService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/event.service.ts b/src/app/demo/service/event.service.ts index 72f5123..67580eb 100644 --- a/src/app/demo/service/event.service.ts +++ b/src/app/demo/service/event.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class EventService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/icon.service.ts b/src/app/demo/service/icon.service.ts index 75a8502..3213c61 100644 --- a/src/app/demo/service/icon.service.ts +++ b/src/app/demo/service/icon.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { map } from 'rxjs/operators'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class IconService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/node.service.ts b/src/app/demo/service/node.service.ts index 260fb55..08ed6b5 100644 --- a/src/app/demo/service/node.service.ts +++ b/src/app/demo/service/node.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { TreeNode } from 'primeng/api'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class NodeService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/photo.service.ts b/src/app/demo/service/photo.service.ts index 05c5656..bc156f2 100644 --- a/src/app/demo/service/photo.service.ts +++ b/src/app/demo/service/photo.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Image } from '../api/image'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class PhotoService { constructor(private http: HttpClient) { } diff --git a/src/app/demo/service/product.service.ts b/src/app/demo/service/product.service.ts index b08cf75..dc9dedb 100644 --- a/src/app/demo/service/product.service.ts +++ b/src/app/demo/service/product.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Product } from '../api/product'; -@Injectable() +@Injectable({ providedIn: 'root'}) export class ProductService { constructor(private http: HttpClient) { } diff --git a/src/main.ts b/src/main.ts index 7e64151..82cd469 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,30 +1,21 @@ import { enableProdMode, importProvidersFrom } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - - import { environment } from './environments/environment'; import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app/app.component'; -import { AppRoutingModule } from './app/app-routing.module'; -import { ProductService } from './app/demo/service/product.service'; -import { PhotoService } from './app/demo/service/photo.service'; -import { NodeService } from './app/demo/service/node.service'; -import { IconService } from './app/demo/service/icon.service'; -import { EventService } from './app/demo/service/event.service'; -import { CustomerService } from './app/demo/service/customer.service'; -import { CountryService } from './app/demo/service/country.service'; +import { APP_ROUTES } from './app/app-routing.module'; import { LocationStrategy, HashLocationStrategy } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { provideAnimations } from '@angular/platform-browser/animations' +import { HttpClientModule } from '@angular/common/http'; if (environment.production) { - enableProdMode(); + enableProdMode(); } bootstrapApplication(AppComponent, { providers: [ - importProvidersFrom(AppRoutingModule), + importProvidersFrom(RouterModule.forRoot(APP_ROUTES), HttpClientModule), + provideAnimations(), { provide: LocationStrategy, useClass: HashLocationStrategy }, - CountryService, CustomerService, EventService, IconService, NodeService, - PhotoService, ProductService - ] -}) - .catch(err => console.error(err)); + ], +}).catch((err) => console.error(err));