cobuild-angular-stack
Version:
Base stack angular sass jade gulp
37 lines (35 loc) • 1.46 kB
JavaScript
/**
* Created by garusis on 19/06/16.
*/
(function (module) {
module
.directive('onboardingRemoveEmpty', onboardingRemoveEmptyDirective);
onboardingRemoveEmptyDirective.$inject = ['ROKK3RLABS_ONBOARDING_CONSTANTS'];
function onboardingRemoveEmptyDirective(ROKK3RLABS_ONBOARDING_CONSTANTS) {
return {
priority: -1000,
link: function (scope, element, attr) {
var unwatch = scope.$watch(function () {
return element.get(0).parentElement.parentElement;
}, function (aParent) {
if (aParent) {
unwatch();
var ulParent = aParent.parentElement.parentElement;
element.remove();
scope.$watch(function () {
return ulParent.children.length;
}, function () {
angular.forEach(ulParent.children, function (child) {
var $child = angular.element(child);
if (!child.firstElementChild.firstElementChild.firstElementChild) {
$child.remove();
}
});
});
}
});
},
restrict: 'E'
};
}
})(angular.module('rokk3rlabs.onboarding'));