Reputation: 1032
So I have a component that looks like this:
export abstract class CrudAddEditComponent<U extends DomainObject, T extends BaseService<U>>
extends SimpleComponent implements OnDestroy, OnInit {
constructor(messageService: MessageService,
protected service: T,
protected route: ActivatedRoute,
logger: NGXLogger) {
super(messageService, logger);
}
with the new decorator requirement what should I use on this class?
@Directive doesn't work because I get "Uncaught Error: Directives cannot inherit Components"
If I use @Component( {template: ''} ) I run into issues with my generics:
src/app/shared/components/base.components.ts:175:35 - error NG2003: No suitable injection token for parameter 'service' of class 'CrudAddEditComponent'.
Consider using the @Inject decorator to specify an injection token.
How do I decorate an abstract class that uses lifecycle methods like OnInit and extends another class with Generics?
Upvotes: 0
Views: 1169
Reputation: 1032
I think I figured it out, one of the parent classes didn't have the @Directive decorator, so I made sure everything up the food chain used @Directive() and they I was good to go.
@Directive()
export abstract class CrudAddEditComponent<U extends DomainObject, T extends BaseService<U>>
extends SimpleComponent implements OnDestroy, OnInit {
Upvotes: 0