Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.
This repository was archived by the owner on Apr 24, 2026. It is now read-only.

[Question] Is it possible to bind Subscribers to Angular's DI system? #28

@JeongJun-Lee

Description

@JeongJun-Lee

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 {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions