angular.module('tasks', ['ngRoute']) .directive('tabs', function () { return { restrict: 'A', transclude: true, scope: { style: "@tabs" }, controller: [ "$scope", function ($scope) { $scope.panels = []; $scope.select = function (i) { angular.forEach($scope.panels, function (p) { p.selected = false; }); $scope.panels[i].selected = true; }; this.addPanel = function (panel) { if ($scope.panels.length === 0) { panel.selected = true; } $scope.panels.push(panel); }; }], template: '