I am trying to create a generic directive which will take a class type for rule validation and according to the rule in the class the directive will either show or hide an e
Just update for Angular version 10+:
@Injectable({
providedIn: 'any'
})
export class AdminOnly { ... }
import { Injector } from '@angular/core';
...
const injector: Injector = Injector.create({
providers: [{provide: AdminOnly, deps: []}]
});
const adminOnly: AdminOnly = injector.get(AdminOnly);
let show = adminOnly.shouldShowElement();
...
See more