我的应用程序中有一个下拉菜单。这是ng-multiselect-drop-down。它有一个错误。在这里,我能够选择值,并且它们会正确显示,但是当我取消选择一个值时,它不会从值列表中减去。所以我发现,我们可以使用ngOnChanges。但是,我无法执行。 我实现的代码是-
app.component.ts
export class NodeVennComponent implements OnInit, OnChanges {
@Input() selectedItemsSelected: any[];
ngOnChanges(changeRecord: SimpleChanges) {
if(changeRecord['selectedItemsSelected'] !== undefined){
this.selectedItemsSelected = changeRecord['selectedItemsSelected'].currentValue;
console.log("this.selectedItemsSelected, ngOnChanges = ", this.selectedItemsSelected)
}
console.log('SimpleChanges It works!');
}
//code
}
app.component.html
<div >
<br>
<br>
<div>
<p>Select {{menuItem}} </p>
<p style="width:50%">
<ng-multiselect-dropdown [placeholder]="'Select API Object'" [data]="dropdownListSelected" [(ngModel)]="selectedItemsSelected"
[settings]="dropdownSettingsSelected" (onSelect)="onItemSelectSelected($event)" (onSelectAll)="onSelectAllSelected($event)">
</ng-multiselect-dropdown>
</p>
</div>
<!-- margin-left:550px -->
<div *ngIf="apiSelect">
<button class="btn btn-dark" (click)="nodalGraphSelectSingle()" style=" margin: auto; display:block"> Select API Object</button>
<br>
<br>
</div>
</div>
图像显示我选择了许多值,然后取消选择它们,但this.selectedItems的值仍然是这些多个值。请帮助解析并选择确切的值数。