Skip to content

Instantly share code, notes, and snippets.

@Xanir
Last active August 29, 2015 14:03
Show Gist options
  • Save Xanir/ac55fd3065904b6c06cf to your computer and use it in GitHub Desktop.
Save Xanir/ac55fd3065904b6c06cf to your computer and use it in GitHub Desktop.
AutoComplete Grouping Directive
Use in row template for AutoComplete hints.
module.directive('grouping', function($timeout) {
return {
restrict: 'AE',
link: function (scope, element, attr) {
$timeout(function() {
var groupClass = scope.groupClass;
var groupLabel = scope.groupLabel;
var newElem = angular.element('<div class="' + groupClass + '">' + groupLabel + '</div>');
var parentElem = angular.element(element.parent());
parentElem.after(newElem);
newElem.after(parentElem);
}, 0, false);
}
};
});
Related CSS:
.groupClass ~ .groupClass {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment