-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollapsable_panel_controller.html
62 lines (57 loc) · 2.78 KB
/
collapsable_panel_controller.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Angularjs Collapsable Panel simple</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<style>
body{ background:#F5F5F5;}
section{ margin-top:20px;}
.nav-pills li a{color:#FFF; font-size:16px; background: #272e35;border-radius: 4px 4px 0 0;}
.nav-pills > li > a:focus,.nav-pills > li > a:hover,.nav-pills > li.active > a, .nav-pills > li.active > a:focus, .nav-pills > li.active > a:hover{ background:#009640;}
.panel{ padding:15px; border:#DDD 1px solid;}
</style>
</head>
<body ng-app="myApp">
<section class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1" ng-controller="PanelController as panel">
<ul class="nav nav-pills">
<li ng-class="{active : panel.isSelected(1)}">
<a href ng-click="panel.selectTab(1)">Tab 1</a>
</li>
<li ng-class="{active : panel.isSelected(2)}">
<a href ng-click="panel.selectTab(2)">Tab 2</a>
</li>
<li ng-class="{active : panel.isSelected(3)}">
<a href ng-click="panel.selectTab(3)">Tab 3</a>
</li>
</ul>
<div class="panel">
<div class="panel-body" ng-show="panel.isSelected(1)">
<h3>Tab 1 Content</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi commodi facere odit alias velit ducimus accusantium maiores, mollitia vitae eum quae maxime labore, quia non consequatur culpa similique, molestiae dicta.</p>
</div>
<div class="panel-body" ng-show="panel.isSelected(2)">
<h3>Tab 2 Content</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi commodi facere odit alias velit ducimus accusantium maiores, mollitia vitae eum quae maxime labore, quia non consequatur culpa similique, molestiae dicta.</p>
</div>
<div class="panel-body" ng-show="panel.isSelected(3)">
<h3>Tab 3 Content</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi commodi facere odit alias velit ducimus accusantium maiores, mollitia vitae eum quae maxime labore, quia non consequatur culpa similique, molestiae dicta.</p>
</div>
</div>
</section>
<script>
var app = angular.module('myApp',[]);
app.controller("PanelController",function(){
this.tab=1;
this.selectTab=function(setTab){
this.tab = setTab;
};
this.isSelected=function(checkTab){
return this.tab === checkTab;
};
});
</script>
</body>
</html>