Reputation: 821
My angular app showing above error message when it pass thought sonar scan. Is there any way to fixed it.
I want to pass 8 or 9 dependency but sonar lint not allowing. Is there any alternate way to make it possible?
Upvotes: 17
Views: 19569
Reputation: 3036
You can use dynamic service injection in the component. In that case it will have one parameter and you can inject as many service as you want.
import { Component, Injector } from '@angular/core';
import { MyService } from './my.service';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
myService : MyService;
constructor(private injector : Injector){
this.myService = injector.get<MyService>(MyService);
}
}
Upvotes: 33