scope.addCustom = function (val) {
if (val) {
var option = {};
if (typeof attrs.create === 'function') {
option = scope.create({ input: val });
} else {
option[scope.labelAttr] = val;
option[scope.valueAttr || 'value'] = val;
}
scope.options.push(option);
scope.set(option);
}
};
Which can be reused here too:
case KEYS.enter:
case KEYS.comma:
if (scope.isOpen) {
if (scope.filteredOptions.length) {
scope.set();
} else if (attrs.create) {
scope.addCustom(e.target.value);
}
e.preventDefault();
}
break;
Where we added the new custom tag stuff it doesn't allowed you to click the custom tag to add it:
Suggest you modify to be:
And add the function to scope:
Which can be reused here too: