Files
redash/client/app/components/tab-nav/index.js
2019-01-31 11:21:45 +02:00

24 lines
598 B
JavaScript

function controller($location) {
this.tabs.forEach((tab) => {
if (tab.isActive) {
tab.active = tab.isActive($location.path());
} else {
tab.active = $location.path().startsWith(`/${tab.path}`);
}
});
}
export default function init(ngModule) {
ngModule.component('tabNav', {
template: '<ul class="tab-nav bg-white">' +
'<li ng-repeat="tab in $ctrl.tabs" ng-class="{\'active\': tab.active }"><a ng-href="{{tab.path}}">{{tab.name}}</a></li>' +
'</ul>',
controller,
bindings: {
tabs: '<',
},
});
}
init.init = true;