[ad_1]
I’ve got some issues with Angular which i’m not very familiar with.
I’d like to create a component which can be called by others like that :
<app-mycomponent [arrayOfServices]=[Services<Model1>, Services<Model2>, ...]></app-mycomponent>
As you can see I’ve got a generic service which implements some basic functions, and each model implements his own functions in an derived service.
I would like to be able to pass to the component constructor an array of services :
@Component({
selector: 'app-crudadmin',
templateUrl: './crudadmin.component.html',
styleUrls: ['./crudadmin.component.scss']
})
export class CRUDadminComponent implements OnInit {
constructor(private formBuilder: FormBuilder,
private services: Services<T>[]) {
}
ngOnInit(): void {
}
}
But this code is not allowed and answers me some errors:
Error:
src/app/components/private/admin/crudadmin/crudadmin.component.ts:14:23
- error NG2003: No suitable injection token for parameter ‘services’ of class ‘CRUDadminComponent’. Consider using the @Inject decorator
to specify an injection token.14 private services: Service[]) {
Any help in order to solve my problem would be nice, i’m really struggling on this problem.
Thanks a lot
[ad_2]