Here is a snippet of code that I am struggling with:
<div ng-repeat="category in categories">
<div ng-repeat="(key, value) in category">
{{ key + ":"}}
<select id={{key}} class="my_select"
data-ng-model="key.type"
data-ui-select2="{}" multiple>
<option ng-repeat="c in value"
ng-selected="(filters[key].length>0) && (filters[key].indexOf(c.trim()) !== -1)" >
{{c.trim()}}</option>
</select>
</div>
</div>
In my controller, I have the following code which does not seem to work (console log does not display anything when selection changes):
$scope.$watch('key.type', function(newValue, oldValue){
console.log("" +newValue + " " + oldValue);
}, true);
I'm looking for a way to watch these selects in this specific situation. I have tried various solutions related to Angular, ng_repeat, and ng_model but none of them have resolved my issue. Any assistance would be greatly appreciated.
This is what I aim to achieve: I have categories like [{category : [ laptop, TV]}, {cpu : [ Core i5, Core i7]}] and I want to create two select elements to retrieve selected data using select2 with multiple items.