I need to use ng-select
directive inside SweetAlert2
, the following code doesn't work:
const { value: formValues } = await swal.fire({
title: 'Multiple inputs',
html:
'<ng-select id="selectedItems" [items]="'+this._data+'" bindLabel="name"' +
'placeholder="Items" [multiple]="true">' +
'</ng-select>',
focusConfirm: false,
preConfirm: () => {
return [
document.getElementById('parcoursSelected').value
]
}
})
if (formValues) {
swal.fire(JSON.stringify(formValues))
}
There are two problems:
Thank you in advance
As far as I know from previous experience using sweet alert and Angular 2+, sweet alert code is injected only on button push, after which it is not recompiled through angular, and therefore you cannot add directives in your swal HTML and expect them to work.