import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from 'src/app/home/home.component';
import { FavoriteComponent } from 'src/app/favorite/favorite.component';
import { AccountComponent } from 'src/app/account/account.component';
import { LoginComponent } from 'src/app/login/login.component';
import { RegisterComponent } from 'src/app/register/register.component';
import { InfoComponent } from 'src/app/info/info.component';
import { guards } from 'src/app/store/guards';
const routes: Routes = [
{ path: 'home', component: HomeComponent, canActivate: guards },
{ path: 'favorite', component: FavoriteComponent, canActivate: guards },
{ path: 'account', component: AccountComponent, canActivate: guards },
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'info', component: InfoComponent }
]
@NgModule({
declarations: [
HomeComponent,
FavoriteComponent,
AccountComponent,
LoginComponent,
RegisterComponent
InfoComponent
],
imports: [
CommonModule,
RouterModule.forChild(routes),
]
})
export class ProductModule { }
Модуль приложения
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './shared/modules/app-routing.module';
import { BrowserModule } from '@angular/platform-browser';
import { environment } from 'src/environments/environment';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { RouterStateSerializer, StoreRouterConnectingModule, RouterState } from '@ngrx/router-store';
import { reducer, CustomSerializer } from './storeRouter';
import { reducers, effects } from './store';
import { AppComponent } from './app.component';
import { NavbarComponent } from './navbar/navbar.component';
import { HomeComponent } from './home/home.component';
import { FavoriteComponent } from './favorite/favorite.component';
import { InfoComponent } from './info/info.component';
import { AccountComponent } from './account/account.component';
import { LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';
@NgModule({
declarations: [
AppComponent,
NavbarComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
HttpClientModule,
StoreRouterConnectingModule.forRoot({
routerState: RouterState.Minimal,
}),
EffectsModule.forRoot(effects),
StoreModule.forRoot(reducer, {
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false,
strictStateSerializability: false,
strictActionSerializability: false,
},
}),
StoreModule.forFeature('products', reducers),
// Only a tool for developers will delete on products
StoreDevtoolsModule.instrument({
maxAge: 25,
logOnly: environment.production,
}),
],
providers: [{ provide: RouterStateSerializer, useClass: CustomSerializer }],
bootstrap: [AppComponent]
})
export class AppModule { }