-
Notifications
You must be signed in to change notification settings - Fork 57
Description
I tried to bind Subscriber to Angular DI like code below. But it look like not working, because this.auditsProv is always Undefined. If it's not impossible, should I have to use another DI for Subscribers like TypeDI(https://github.com/typeorm/typeorm-typedi-extensions)?
[post-subs.ts]
import { Injectable } from '@angular/core';
import { EventSubscriber, EntitySubscriberInterface, InsertEvent } from "typeorm";
import { AuditsProvider } from '../providers/audits/audits';
@Injectable()
@EventSubscriber()
export class PostSubscriber implements EntitySubscriberInterface {
constructor(private auditsProv: AuditsProvider) {
console.log(this.auditsProv);
}
/**
- Called before entity insertion.
*/
beforeInsert(event: InsertEvent) {
console.log(BEFORE ENTITY INSERTED:
, event.entity);
this.auditsProv.save();
}
}
[app.module.ts]
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuditsProvider,
PostSubscriber
]
})
export class AppModule {}