diff --git a/src/bootstrap/match-multiple.tpl.html b/src/bootstrap/match-multiple.tpl.html
index be9e92da7..1a5a619c8 100644
--- a/src/bootstrap/match-multiple.tpl.html
+++ b/src/bootstrap/match-multiple.tpl.html
@@ -5,7 +5,7 @@
tabindex="-1"
type="button"
ng-disabled="$select.disabled"
- ng-click="$selectMultiple.activeMatchIndex = $index;"
+ ng-click="$selectMultiple.selectMatch($index);"
ng-class="{'btn-primary':$selectMultiple.activeMatchIndex === $index, 'select-locked':$select.isLocked(this, $index)}"
ui-select-sort="$select.selected">
×
diff --git a/src/select2/match-multiple.tpl.html b/src/select2/match-multiple.tpl.html
index 8a9dd85b1..abe8a3e4a 100644
--- a/src/select2/match-multiple.tpl.html
+++ b/src/select2/match-multiple.tpl.html
@@ -5,6 +5,7 @@
-->
diff --git a/src/selectize/match-multiple.tpl.html b/src/selectize/match-multiple.tpl.html
index 49d37b2d7..87373438f 100644
--- a/src/selectize/match-multiple.tpl.html
+++ b/src/selectize/match-multiple.tpl.html
@@ -1,6 +1,6 @@
×
-
\ No newline at end of file
+
diff --git a/src/uiSelectMatchDirective.js b/src/uiSelectMatchDirective.js
index ef9bdcf33..6d38b4b68 100644
--- a/src/uiSelectMatchDirective.js
+++ b/src/uiSelectMatchDirective.js
@@ -1,4 +1,4 @@
-uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
+uis.directive('uiSelectMatch', ['uiSelectConfig', '$parse', function(uiSelectConfig, $parse) {
return {
restrict: 'EA',
require: '^uiSelect',
@@ -13,7 +13,7 @@ uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
var theme = getAttribute(parent, 'theme') || uiSelectConfig.theme;
var multi = angular.isDefined(getAttribute(parent, 'multiple'));
- return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
+ return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
},
link: function(scope, element, attrs, $select) {
$select.lockChoiceExpression = attrs.uiLockChoice;
@@ -30,6 +30,7 @@ uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
if($select.multiple){
$select.sizeSearchInput();
+ $select.onMatchSelectCallback = $parse(attrs.onMatchSelect);
}
}
diff --git a/src/uiSelectMultipleDirective.js b/src/uiSelectMultipleDirective.js
index 06de4f134..6d35646f6 100644
--- a/src/uiSelectMultipleDirective.js
+++ b/src/uiSelectMultipleDirective.js
@@ -62,6 +62,21 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
return true;
};
+ // Fire onMatchSelect when a match is selected from ui-select-matches list.
+ ctrl.selectMatch = function(index) {
+ ctrl.activeMatchIndex = index;
+ var locals = {},
+ selectedMatch = $select.selected[index];
+
+ locals[$select.parserResult.itemName] = selectedMatch;
+
+ if($select.onMatchSelectCallback) {
+ $select.onMatchSelectCallback($scope, {
+ $item: selectedMatch,
+ $model: $select.parserResult.modelMapper($scope, locals)
+ });
+ }
+ };
}],
controllerAs: '$selectMultiple',