我在我的角度包中使用 ngx select 下拉菜单我已经正确完成了所有操作并且它工作正常但是在运行构建时我遇到了一个错误,我被卡住并且无法继续前进。请帮忙。在下拉组件中 HTML (change)="selectionChanged($event)" 是唯一使用的函数,参数在 ts 文件中接收。!在 ts 中传递和使用的参数也仍然出现错误,不明白问题
HTML的根本原因是什么
<ngx-select-dropdown *ngIf="dropdownList" (change)="selectionChanged($event)"
[options]="selectList" [config]="config">
</ngx-select-dropdown>
TS
import { Component, Output, EventEmitter, Input, OnChanges } from '@angular/core';
@Component({
selector: 'dropdown-template',
templateUrl: './dropdown.component.html',
styleUrls: ['./dropdown.component.scss'],
})
export class DropdownComponent implements OnChanges {
@Input() selectList;
@Output() dropdownSelected = new EventEmitter<any>();
public config = {};
public dropdownList: any;
constructor() { }
ngOnChanges() {
if (this.selectList) {
this.getValue(this.selectList);
}
this.config = {
displayKey: 'value',
search: true,
height: 'auto',
customComparator: () => { },
moreText: 'more',
noResultsFound: 'No results found!',
searchPlaceholder: 'Search',
searchOnKey: ''
};
}
// selected change array
selectionChanged = (e) => {
if (this.multiSelection) {
this.dropdownSelected.emit(e);
} else {
this.dropdownSelected.emit(e.value);
}
}
}
模块.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { DropdownComponent } from './dropdown.component';
import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { SelectDropDownModule } from 'ngx-select-dropdown';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [DropdownComponent],
imports: [
HttpClientModule,
CommonModule,
SelectDropDownModule,
FormsModule
],
providers: [DropdownComponent],
exports: [DropdownComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class DropdownModule { }