Component select2 with AngularJS

0

Good afternoon

Does anyone use the select2 component ( link ) to create dropdown components?

I'm going through the following problem, I have two components in a javascript that are placed on the screen as the user adds new lines. And in these components of type select2, the null-tag tag of AngularJS is placed pointing to an attribute of an item for example, but when it is called via AJAX the item with its attributes AngularJS does not realize that the value should be changed and the class of the component continues as ng-pristine instead of ng-dirty, using Google Chrome the input where it is stored the item code does not turn pink at the time of the change, indicating that the value continued the same as received when the user reported to create a new line of items.

Html in JavaScript that mounts the component on screen:

<input  ng-model='item.oid' data-url='${pageContext.request.contextPath}/cadastros/item' new-item='true' data-id='oid' data-text='descricao' name='itens[{{$index}}].item.oid' id='item{{$index}}' type='select2' style=' min-width: 300px;' class='form-control' />

    
asked by anonymous 23.06.2015 / 19:42

1 answer

1

To use the Select2 component in AngularJS, I recommend using this here .

To have the behavior you are looking for you will need to create a property on the Controller (or whatever else) you are using and manipulate this property. Whenever there is a change in the property with the array of objects to be displayed in the component the update will occur on screen.

    
23.06.2015 / 20:18