1
Hello guys I am using the plugin of Select2 in my project. I need to create several selects2 dynamically, by angular. I have an object array (with id, name) and accurate from an event, in a function generate a select for each object, and can differentiate the key by id. Can someone 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 isn’t working, it’s just a part of getting an idea. I tried to use it with idea in some links I saw, but I got nothing yet.
You can put an example of what is in the filter object?
– Sorack