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?
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With