Is there an angular 2+ multi-select dropdown that has a custom trigger button?
I'm looking for something similar to the old AngularJS "custom trigger element using transclusion" (here)...however, ng-select, ng-multiselect-dropdown and other do not seem to offer this.
I'm looking for any viable options with example code.
Complementary my comment, the component becomes
.html
<div ngbDropdown class="d-inline-block" autoClose="outside">
<button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>
{{data.length?data.length+' checked':'Select'}}
</button>
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
<button class="dropdown-item" *ngFor="let option of options" (click)="check(option)">
<span *ngIf="option.checked">~ </span>{{option.label}}
</button>
</div>
</div>
.ts
import {Component,Input,Output,EventEmitter} from '@angular/core';
@Component({
selector: 'ngbd-dropdown-basic',
templateUrl: './dropdown-basic.html'
})
export class NgbdDropdownBasic {
@Input() options;
@Output() change = new EventEmitter<any[]>();
data:any[]=[];
check(option)
{
option.checked=!option.checked;
this.data=this.options.filter((x:any)=>x.checked).map(x=>
{
return {id:x.id,label:x.label}
})
this.change.emit(this.data);
}
}
You can easy convert in custom form control