Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit e3d31dc

Browse files
committed
Extract into function to avoid duplicate code
1 parent 8e59e1a commit e3d31dc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/uiSelectController.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ uis.controller('uiSelectCtrl',
388388
return isDisabled;
389389
};
390390

391+
function _replaceTaggingLabelAndTrim(item, taggingLabel) {
392+
return item.replace(taggingLabel, '').trim();
393+
}
391394

392395
// When the user selects an item with ENTER or clicks the dropdown
393396
ctrl.select = function(item, skipFocusser, $event) {
@@ -431,7 +434,7 @@ uis.controller('uiSelectCtrl',
431434
// if item type is 'string', apply the tagging label
432435
} else if ( typeof item === 'string' ) {
433436
// trim the trailing space
434-
item = item.replace(ctrl.taggingLabel,'').trim();
437+
item = _replaceTaggingLabelAndTrim(item, ctrl.taggingLabel);
435438
}
436439
}
437440
}
@@ -441,7 +444,7 @@ uis.controller('uiSelectCtrl',
441444
return;
442445
}
443446
} else if ( typeof item === 'string') {
444-
item = item.replace(ctrl.taggingLabel,'').trim();
447+
item = _replaceTaggingLabelAndTrim(item, ctrl.taggingLabel);
445448
}
446449
_resetSearchInput();
447450
$scope.$broadcast('uis:select', item);

0 commit comments

Comments
 (0)