standalone step 3 and all providers in root
This commit is contained in:
parent
b79258ea6d
commit
268b117350
@ -1,11 +1,8 @@
|
|||||||
import { RouterModule } from '@angular/router';
|
import { Route } from '@angular/router';
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { NotfoundComponent } from './demo/components/notfound/notfound.component';
|
import { NotfoundComponent } from './demo/components/notfound/notfound.component';
|
||||||
import { AppLayoutComponent } from "./layout/app.layout.component";
|
import { AppLayoutComponent } from "./layout/app.layout.component";
|
||||||
|
|
||||||
@NgModule({
|
export const APP_ROUTES: Route[] = [
|
||||||
imports: [
|
|
||||||
RouterModule.forRoot([
|
|
||||||
{
|
{
|
||||||
path: '', component: AppLayoutComponent,
|
path: '', component: AppLayoutComponent,
|
||||||
children: [
|
children: [
|
||||||
@ -21,9 +18,4 @@ import { AppLayoutComponent } from "./layout/app.layout.component";
|
|||||||
{ path: 'landing', loadChildren: () => import('./demo/components/landing/landing.module').then(m => m.LandingModule) },
|
{ path: 'landing', loadChildren: () => import('./demo/components/landing/landing.module').then(m => m.LandingModule) },
|
||||||
{ path: 'notfound', component: NotfoundComponent },
|
{ path: 'notfound', component: NotfoundComponent },
|
||||||
{ path: '**', redirectTo: '/notfound' },
|
{ path: '**', redirectTo: '/notfound' },
|
||||||
], { scrollPositionRestoration: 'enabled', anchorScrolling: 'enabled', onSameUrlNavigation: 'reload' })
|
];
|
||||||
],
|
|
||||||
exports: [RouterModule]
|
|
||||||
})
|
|
||||||
export class AppRoutingModule {
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class CountryService {
|
export class CountryService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Customer } from '../api/customer';
|
import { Customer } from '../api/customer';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class CustomerService {
|
export class CustomerService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class EventService {
|
export class EventService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class IconService {
|
export class IconService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { TreeNode } from 'primeng/api';
|
import { TreeNode } from 'primeng/api';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class NodeService {
|
export class NodeService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Image } from '../api/image';
|
import { Image } from '../api/image';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class PhotoService {
|
export class PhotoService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Product } from '../api/product';
|
import { Product } from '../api/product';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root'})
|
||||||
export class ProductService {
|
export class ProductService {
|
||||||
|
|
||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
25
src/main.ts
25
src/main.ts
@ -1,19 +1,12 @@
|
|||||||
import { enableProdMode, importProvidersFrom } from '@angular/core';
|
import { enableProdMode, importProvidersFrom } from '@angular/core';
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
||||||
|
|
||||||
|
|
||||||
import { environment } from './environments/environment';
|
import { environment } from './environments/environment';
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
import { bootstrapApplication } from '@angular/platform-browser';
|
||||||
import { AppComponent } from './app/app.component';
|
import { AppComponent } from './app/app.component';
|
||||||
import { AppRoutingModule } from './app/app-routing.module';
|
import { APP_ROUTES } 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 { LocationStrategy, HashLocationStrategy } from '@angular/common';
|
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) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
@ -21,10 +14,8 @@ if (environment.production) {
|
|||||||
|
|
||||||
bootstrapApplication(AppComponent, {
|
bootstrapApplication(AppComponent, {
|
||||||
providers: [
|
providers: [
|
||||||
importProvidersFrom(AppRoutingModule),
|
importProvidersFrom(RouterModule.forRoot(APP_ROUTES), HttpClientModule),
|
||||||
|
provideAnimations(),
|
||||||
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
||||||
CountryService, CustomerService, EventService, IconService, NodeService,
|
],
|
||||||
PhotoService, ProductService
|
}).catch((err) => console.error(err));
|
||||||
]
|
|
||||||
})
|
|
||||||
.catch(err => console.error(err));
|
|
||||||
|
Loading…
Reference in New Issue
Block a user