![](/img/trans.png)
[英]Angular 7 - build --prod failed with error: Can't resolve all parameters for
[英]Angular - Can't resolve ALL Parameters for component ng build --prod
我試圖構建我的角度應用程序,但由於此錯誤而失敗
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]).
這是COMPONENT的代碼。 這是基本組成部分。 這里缺少什么嗎? 也許構造函數屬性有問題?
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
)
{}
............
.....
}
錯誤:無法解析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:(?,[對象對象],[對象對象],[對象對象])。
?
錯誤消息中的問號表明構造函數中的哪個參數未知。
constructor(
protected _systemListTitle : string,
protected _svc: SimpleLookupBaseService,
protected _router: Router,
protected _route: ActivatedRoute
)
第一個參數正在觸發?
問號。
類型string
不是可注入類型。 角注入器使用參數的類型來推斷應使用的injectable
提供程序。
要注入string
參數,您必須在您的NgModule
定義之一中提供一個令牌。
export const LIST_TITLE: InjectionToken<string> = new InjectionToken<string>('LIST_TITLE');
@NgModule({
providers: [{provide: LIST_TITLE, useValue: 'My List Title'}]
})
現在,您可以將令牌手動注入到構造函數中。
constructor(
@Inject(LIST_TITLE) protected _systemListTitle : string,
protected _svc: SimpleLookupBaseService,
protected _router: Router,
protected _route: ActivatedRoute
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.