J'ai un projet 4 angulaire avec ce module de noeud pour stocker des données: DarthKurt/ng2-cache-serviceAngular4: Aucun fournisseur pour t! après l'importation module cache-service NG2
Mais je reçois cette erreur, se produit seulement après la compilation avec AOT:
ng construire --prod --aot
ERROR Error: Uncaught (in promise): Error: No provider for t!
J'importer le service de cache de cette façon:
app.modu le.ts
...
import { CacheService } from 'ng2-cache-service';
@NgModule({
declarations: [
...
],
imports: [
...
],
providers: [
CacheService, {
provide: APP_BASE_HREF,
useValue: '/app/ecommerce/'
}],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component, OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { CacheService } from 'ng2-cache-service';
import 'rxjs/Rx';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [ CacheService ]
})
export class AppComponent {
constructor(public http: Http, public cache: CacheService) {}
someFunc() {
this.cache.set('test', 'works');
}
}
Si j'ajoute le CacheService à la liste des importations dans les app.module.ts, je suis toujours obtenir l'erreur suivante:
ERROR in Unexpected value 'CacheService in /Users/rpereira/ecommerce/node_modules/ng2-cache-service/dist/src/services/cache.service.d.ts' imported by the module 'AppModule in /Users/rpereira/ecommerce/src/app/app.module.ts'. Please add a @NgModule annotation.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/rpereira/ecommerce/src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
Ai-je manqué som ething?