Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度-声纳-构造器的参数太多(8)。允许的最大值为7_Angular_Typescript_Sonarqube - Fatal编程技术网

Angular 角度-声纳-构造器的参数太多(8)。允许的最大值为7

Angular 角度-声纳-构造器的参数太多(8)。允许的最大值为7,angular,typescript,sonarqube,Angular,Typescript,Sonarqube,我的angular应用程序在通过思维声纳扫描时显示上述错误消息。有没有办法修理它 我想通过8级或9级,但声纳线头不允许。是否有其他方法使之成为可能?您可以在组件中使用动态服务注入。在这种情况下,它将有一个参数,您可以根据需要注入任意多的服务 import { Component, Injector } from '@angular/core'; import { MyService } from './my.service'; @Component({ selector: 'my-app'

我的angular应用程序在通过思维声纳扫描时显示上述错误消息。有没有办法修理它


我想通过8级或9级,但声纳线头不允许。是否有其他方法使之成为可能?

您可以在组件中使用动态服务注入。在这种情况下,它将有一个参数,您可以根据需要注入任意多的服务

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);
 }
}
从'@angular/core'导入{Component,Injector};
从“/my.service”导入{MyService};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
名称='角度';
myService:myService;
构造函数(专用注入器:注入器){
this.myService=injector.get(myService);
}
}

您可以在组件中使用动态服务注入。在这种情况下,它将有一个参数,您可以根据需要注入任意多的服务

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);
 }
}
从'@angular/core'导入{Component,Injector};
从“/my.service”导入{MyService};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
名称='角度';
myService:myService;
构造函数(专用注入器:注入器){
this.myService=injector.get(myService);
}
}

感谢您的快速回复。它起作用了!谢谢你的快速回复。它起作用了!