Skip to content

Instantly share code, notes, and snippets.

@pankajparkar
Created April 1, 2019 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pankajparkar/ff66a54f84feae4fb16670a42c929cfd to your computer and use it in GitHub Desktop.
Save pankajparkar/ff66a54f84feae4fb16670a42c929cfd to your computer and use it in GitHub Desktop.
.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