primengは、あなたが直接必要とするものを実現するためのAPIを提供していないため、ここで私はそれを行うことができます。
your.component.html
<p-multiSelect #ms [options]="cars" [(ngModel)]="selectedCars"></p-multiSelect>
your.component.ts
import { Renderer} from '@angular/core';
import {MultiSelect} from 'primeng/primeng';
@ViewChild('ms') multiselect: MultiSelect;
constructor(private renderer :Renderer) {}
ngOnInit(){
this.renderer.listenGlobal('document', 'click',()=> {
if (!this.multiselect.selfClick && !this.multiselect.panelClick && this.multiselect.overlayVisible) {
console.log('multiselect will hide'); // write code here to execute when multiselect overlay get dismissed/hidden
// this.selectedCars will have all the selected values.
}
});
}
Primengユーザーが自分自身を複数選択以外の場所をクリックすると複数選択オーバーレイを却下する同じロジックを使用します。 将来的に、希望の結果を得るための直接的な方法を提供している場合は、この作業を行う必要はありません。
私が必要としたもの。 – ssingh