This only works with a static list because you do the select-items parsing on load. The parse needs to happen any time the select-items list changes. For example, pulling the list of items in an http request. I solved it setting up a watch on selectItems and parsing it any time that it changes.
scope.$watch('selectItems', function (newValue, oldValue) {
if (newValue === oldValue) {
return;
}
scope.mdSelectItems = newValue;
parseSelectedItems();
})
function parseSelectedItems() {
angular.forEach(scope.mdSelectItems, function (obj, key) {
obj.mainTitle = '';
angular.forEach(subString, function (field, fkey) {
if (obj[field] != null) {
obj.mainTitle += obj[field].toString();
obj.mainTitle += ' ';
}
});
});
}
This only works with a static list because you do the select-items parsing on load. The parse needs to happen any time the select-items list changes. For example, pulling the list of items in an http request. I solved it setting up a watch on selectItems and parsing it any time that it changes.