Hello everyone, I'm using the select2 plugin in my project. I need to create multiple selects2 dynamically, by angular. I have a vector of objects (with id, name) and I need from an event, in a function to generate a select to of each object, being able to differentiate the key by id. Can anyone help me?
Function:
angular.forEach(camada.filtros, function (filtro)
{
var s = "select_multiple"+filtro.id;
$('#myModalBody').on('DOMNodeInserted', s, function () {
$(this).select2();
});
HTML:
<div class="modal-body" id="myModalBody" ng-repeat="filtro in filtros">
<select class="select_multiple" id="select_multiple{{filtro.id}}" multiple="multiple" style="width: 400px;" ng-model="filtrosCamadasSelecionadas" >
<option>asdasd</option>
<option>vvvvv</option>
<option>bbbbbb</option>
<option>aaaaaaa</option>
<option>xxxxxx</option>
</select>
</div>
The code above is not working, it's only a part to get an idea. I tried to use this idea with some links I saw, but I did not get anything yet.