【发布时间】:2022-01-14 00:23:35
【问题描述】:
我只为礼品卡模块实现缓存,并且我创建了 http-cache.service 和缓存拦截器。当我在 app.module.ts 中添加服务时,它可以工作,但我只需要为礼品卡单独实现这个。当我单独为礼品卡做它不起作用。这是我的代码
giftcard-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { GiftcardComponent } from './list/giftcard.component';
import { GiftcardtransactionComponent } from './giftcardtransaction/giftcardtransaction.component';
const routes: Routes = [
{
path: '',
component: GiftcardComponent
},
{
path: 'sales',
component: GiftcardtransactionComponent,
data: { breadcrumb: "Sales" }
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class GiftCardRoutingModule { }
giftcard.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { GiftcardComponent } from './list/giftcard.component';
import { GiftcardtransactionComponent } from './giftcardtransaction/giftcardtransaction.component';
import { GiftCardRoutingModule } from './giftcard-routing.module';
import { CacheInterceptor } from '../helper/interceptors/cache.interceptor';
import { HttpCacheService } from '../helper/services/cache/http-cache.service';
import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
@NgModule({
imports: [
CommonModule,
GiftCardRoutingModule,
RouterModule
],
declarations: [
GiftcardComponent,
GiftcardtransactionComponent
],
providers: [
HttpCacheService,{ provide: HTTP_INTERCEPTORS, useClass: CacheInterceptor, multi: true }
],
})
export class GiftCardModule { }
【问题讨论】:
标签: angular module angular-http-interceptors http-caching angular-providers