gpt4 book ai didi

javascript - Uncaught Error : Can't resolve all parameters for 'ComponentName' : ([object Object],?)

转载 作者:行者123 更新时间:2023-12-05 02:58:10 25 4
gpt4 key购买 nike

不知道为什么会报错

compiler.js:2175 Uncaught Error: Can't resolve all parameters for ClauseListComponent: ([object Object], ?).
at syntaxError (compiler.js:2175)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:20399)
at CompileMetadataResolver._getTypeMetadata (compiler.js:20294)
at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:19923)
at CompileMetadataResolver._getEntryComponentMetadata (compiler.js:20494)
at compiler.js:20486
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getEntryComponentsFromProvider (compiler.js:20485)
at compiler.js:20456
at Array.forEach (<anonymous>)

我正在尝试使用 ngbModal,这是我目前所做的。

clause.module.ts

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
declarations: [ModuleListComponent,ClauseListComponent,ModifyClauseComponent],
imports: [
NgbModule

clauselist.html

<ng-template #content let-modal >
<div class="modal-header">
<h4 class="h4Header" id="modal-basic-title">Title</h4>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
CheckMate!
</div>
<div class="modal-footer">
<button mat-flat-button class="text-btn" (click)="modal.close('Save click')">ENROLL NOW</button>
<button mat-flat-button class="text-btn" (click)="modal.close('Save click')">Later</button>
</div>
</ng-template>
<button mat-flat-button class="primary-btn marR16" (click)="open(content)">Modal dialog</button>

.ts文件

import {NgbModal} from '@ng-bootstrap/ng-bootstrap';

constructor(private service : OfferClauseService,private modalService: NgbModal) { }
open(content) {
this.modalService.open(content,{windowClass:'custom_modal'})
}

配置

    "lib": [
"es2018",
"dom"
]

指望你们!请询问是否需要更多说明。

最佳答案

您需要将其导入到您的 NgModule 中,而不是将其注入(inject)到您的组件中。

import { ModalModule } from 'ngb-modal';

@NgModule({
imports: [
...
ModalModule,
],

从构造函数中删除 private modalService: NgbModal:

constructor(private service : OfferClauseService,private modalService: NgbModal) { }

而是添加 ModalManager:

export class YourComponent {
@ViewChild('myModal') myModal;
private modalRef;
constructor(private modalService: ModalManager){}

openModal(){
this.modalRef = this.modalService.open(this.myModal, {
...
})
};
...

closeModal(){
this.modalService.close(this.modalRef);
//or this.modalRef.close();
}
}

引用:https://www.npmjs.com/package/ngb-modal

关于javascript - Uncaught Error : Can't resolve all parameters for 'ComponentName' : ([object Object],?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59250853/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com