简体   繁体   English

Angular-无法解析组件ng build --prod的所有参数

[英]Angular - Can't resolve ALL Parameters for component ng build --prod

I was trying to build my angular app but it fails because of this error 我试图构建我的角度应用程序,但由于此错误而失败

 ERROR in : Can't resolve all parameters for SimpleLookupAddEditFormComponent 
 in C:/Users/lastr/Source/Repos/SMATA/Code/ng/smata-ng/src/app/system- 
 list/simple-lookup-add-edit/simple-lookup-add-edit.component.ts: (?, [object 
 Object], [object Object], [object Object]).

Here is the code of the COMPONENT. 这是COMPONENT的代码。 This is a base component. 这是基本组成部分。 Is there anything missing here? 这里缺少什么吗? maybe problems with the constructor properties? 也许构造函数属性有问题?

 import { Component, OnInit } from '@angular/core';
 import { SimpleLookupBaseService } from '../services/simple-lookup-base/simple-lookup-base.service';
 import { ActivatedRoute, Router } from '@angular/router';
 import validationEngine from "devextreme/ui/validation_engine";
 import notify from 'devextreme/ui/notify';

 @Component({
   selector: 'app-simple-lookup-add-edit',
   templateUrl: './simple-lookup-add-edit.component.html',
   styleUrls: ['./simple-lookup-add-edit.component.css']
 })
 export class SimpleLookupAddEditFormComponent implements OnInit {

   newSystemList: {};
   isEditMode:boolean = true;
   selectedSystemList: any;
   title: string;
   saveButtonText: string;
   isPopupVisible:boolean = false;
   entityId:any;

   constructor(
     protected _systemListTitle : string,
     protected _svc: SimpleLookupBaseService,
     protected _router: Router,
     protected _route: ActivatedRoute
   ) 
     {}
 ............
 .....
 }

ERROR in : Can't resolve all parameters for SimpleLookupAddEditFormComponent in C:/Users/lastr/Source/Repos/SMATA/Code/ng/smata-ng/src/app/system- list/simple-lookup-add-edit/simple-lookup-add-edit.component.ts: (?, [object Object], [object Object], [object Object]). 错误:无法解析C:/ Users / lastr / Source / Repos / SMATA / Code / ng / smata-ng / src / app / system-list / simple-lookup-add-edit / simple中SimpleLookupAddEditFormComponent的所有参数-lookup-add-edit.component.ts:(?,[对象对象],[对象对象],[对象对象])。

The ? ? question mark in the error message tells which parameter in the constructor is unknown. 错误消息中的问号表明构造函数中的哪个参数未知。

constructor(
 protected _systemListTitle : string,
 protected _svc: SimpleLookupBaseService,
 protected _router: Router,
 protected _route: ActivatedRoute
) 

The first parameter is triggering the ? 第一个参数正在触发? question mark. 问号。

The type string is not an injectable type. 类型string不是可注入类型。 Angular injector uses the type of the parameters to infer what the injectable provider that should be used. 角注入器使用参数的类型来推断应使用的injectable提供程序。

To inject a string parameter you have to provide a token in one of your NgModule definitions. 要注入string参数,您必须在您的NgModule定义之一中提供一个令牌。

export const LIST_TITLE: InjectionToken<string> = new InjectionToken<string>('LIST_TITLE');

@NgModule({
   providers: [{provide: LIST_TITLE, useValue: 'My List Title'}]
})

Now you can manually inject the token into your constructor. 现在,您可以将令牌手动注入到构造函数中。

constructor(
 @Inject(LIST_TITLE) protected _systemListTitle : string,
 protected _svc: SimpleLookupBaseService,
 protected _router: Router,
 protected _route: ActivatedRoute
) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 7 - build --prod 失败并出现错误:无法解析所有参数 - Angular 7 - build --prod failed with error: Can't resolve all parameters for 错误:使用ng build --prod构建时无法解析Service的所有参数 - ERROR in : Can't resolve all parameters for Service when build with ng build --prod 在ng build --prod期间无法解析验证指令中的所有参数 - Can't resolve all parameters in validation directive during ng build --prod 无法解析 AngularFirestore (PROD Build) 的所有参数 - Can't resolve all parameters for AngularFirestore (PROD Build) Angular 2 - 无法解析组件的所有参数:(?) - Angular 2 - Can't resolve all parameters for component: (?) Angular:无法解析组件的所有参数 - Angular: Can`t resolve all parameters for Component Angular 6:无法解析Component的所有参数(?) - Angular 6: Can't resolve all parameters for Component: (?) 角度,无法解析组件的所有参数 - Angular, can't resolve all parameters for Component 无法解析 Staging &amp; Prod 上的所有参数(AOT、buildOptimizer)(ng serve 有效) - Can't resolve all parameters (AOT, buildOptimizer) on Staging & Prod (ng serve works) ng-bootstrap和Angular 6:无法解析NgbModalRef的所有参数:(?,?,?,?) - ng-bootstrap and Angular 6: Can't resolve all parameters for NgbModalRef: (?,?,?,?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM