Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { inject, InjectOptions, Type } from "@angular/core";
export class RootInjectorGuard {
option: InjectOptions = {
skipSelf: true,
optional: true
};
constructor(type: Type<any>) {
console.log(type.name);
const parent = inject(type, this.option);
if (parent) {
throw Error(`[${type.name}]: Can not create more than one instance`);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment