Created
April 1, 2019 02:58
-
-
Save pankajparkar/ff66a54f84feae4fb16670a42c929cfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.component('tabs', { | |
transclude: true, | |
controllerAs: 'tabs', | |
controller: [function TabsController() { | |
var tabs = this; | |
var panes = tabs.panes = [] | |
tabs.select = function(pane) { | |
angular.forEach(panes, function(p) { | |
p.selected = false; | |
}); | |
pane.selected = true; | |
}; | |
tabs.addPane = function(pane) { | |
if (panes.length === 0) { | |
tabs.select(pane); | |
} | |
tabs.panes.push(pane); | |
}; | |
}], | |
templateUrl: 'tabs.html' | |
}) | |
.component('tab', { | |
require: { | |
tabsCtrl: '^tabs' | |
}, | |
transclude: true, | |
bindings: { | |
details: '<' | |
}, | |
controllerAs: 'tab', | |
controller: function() { | |
var tab = this | |
tab.$onInit = function () { | |
tab.tabsCtrl.addPane(tab.details); | |
} | |
}, | |
templateUrl: 'tab.html' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment