AngularJS MultiSelect
Blogs20152015-05-10
AngularJS Isteven-MultiSelect
I used and updated the isteven-multi-select open-sources: add more variables to pass, change the flow to customize, and specialize the search-filter filed.
<div
multi-select
input-model="$scope.allList"
output-model="$scope.selectedList"
button-label="property1 property2 ..."
selection-mode="multiple"
owner-tool-tip="ToolTip"
min-search-length="3"
is-disabled="true | false"
helper-elements="all none reset filter"
on-open="$scope.functionOpen()"
on-close="$scope.functionClose()"
on-focus="$scope.functionFocus()"
on-blur="$scope.functionBlur()"
default-label="default text">
</div>The following are the codes in link function:
//switch icons(search,clear):
$scope.$watch('inputLabel.labelFilter', function (newVal) {
var buttonToggle = angular.element(element).find('.inputFilter').parent();
if (newVal && newVal.length > 0) {
if (!buttonToggle.hasClass('is-focus')) {
buttonToggle.addClass('is-focus');
}
}
else {
if (buttonToggle.hasClass('is-focus')) {
buttonToggle.removeClass('is-focus');
}
}
});
// the following are from original code for my reference.
angular.element( document ).bind( 'touchmove', onTouchMove);
// unbind document events to prevent memory leaks
$scope.$on( '$destroy', function () {
angular.element( document ).unbind( 'touchstart', onTouchStart);
});