Create items
New items are created in two modes: prompt and autocomplete (default). See relevant examples.
You can set enter (default) and blur trigger for saving
oi-options="item for item in shopArrShort"
ng-model="bundle1"
multiple
oi-select-options="{
newItem: true,
saveTrigger: 'enter blur space . , ;'
}"
You can describe model for new items by newItemModel
oi-options="item.name for item in shopArr"
ng-model="bundle2"
multiple
oi-select-options="{
newItem: true,
newItemModel: {id: null, name: $query, category: 'shoes'}
}"
or by newItemFn which returns new item or promise (it will be useful if you create items in DB)
oi-options="item.name for item in shopArr"
ng-model="bundle3"
multiple
oi-select-options="{
newItem: true,
newItemFn: 'addItem($query)'
}"
var counter = 0;
$scope.addItem = function(query) {
var id = counter++;
return {
id: id,
name: query + '-' + id,
category: "shoes"
};
};
You can use oi-select without oi-options for simple situations or use item.name for item in [] if you need item model but needn't options list
ng-model="bundle4"
multiple
oi-select-options="{
newItem: true
}"