standalone step 3 and all providers in root

This commit is contained in:
Justin McLellan 2023-06-11 07:57:35 -05:00
parent b79258ea6d
commit 268b117350
9 changed files with 34 additions and 51 deletions

View File

@ -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' },
];

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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));