fruitstand
Version:
33 lines • 836 B
JavaScript
var app = angular.module('myApp', []);
app.directive('myTabs', function() {
return {
restrict: 'E',
transclude: true,
scope: {},
controller: function($scope) {
var panes = $scope.panes = [];
$scope.select = function(pane) {
angular.forEach(panes, function(pane) {
pane.selected = false;
});
pane.selected = true;
};
this.addPane = function(pane) {
if (panes.length == 0) {
$scope.select(pane);
}
panes.push(pane);
};
},
templateUrl: 'tabs.html'
};
});
app.directive('myPane', function() {
return { require: '^myTabs', restrict: 'E',
templateUrl: 'pane.html',
transclude: true, scope: { title: '@' },
link: function(scope, element, attrs, tabsCtrl) {
tabsCtrl.addPane(scope);
}
};
});