Select as (lazy loading case)

oi-options="item.id as item.name for item in shopArrFn($query, $selectedAs)" ng-model="bundle" multiple oi-select-options="{ newItem: true, newItemFn: 'addItem($query)', removeItemFn: 'removeItem($item)' }"

Example how to get elements by id and create new in database

$scope.shopArrFn = function(query, selectedAs) { if (querySelectAs) { return getOptionsById(selectedAs); //promise } else { return findOptions(query); //promise } };
$scope.addItem = function(query) { return createOption(query); //promise };
$scope.removeItem = function(item) { return removeOption(item); //promise };

You can optimize this case and don't request all selected items when the new item has been added

{{bundle}}