-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (121 loc) · 4.99 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<html ng-app="myApp">
<head>
<title>Test</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<h1>Hello, world!</h1>
<div ng-controller="myController">
<div ng-controller="myController">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Gobal <span> money </span>
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<collection collection='collections'></collection>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script type="text/javascript">
var myApp = angular.module('myApp',[]);
myApp.controller("myController", ['$scope', myController]);
function myController($scope) {
$scope.collections = [
{
name: 'Europe',
id: 1,
children: [
{
name: 'Italy',
id: 2,
children: [
{
name: 'Rome',
id: 3
},
{
name: 'Milan',
id:4
}
]
},
{
name: 'Spain',
id:5
}
]
},
{
name: 'SouthAmerica',
id:6,
children: [
{
name: 'Brasil',
id:7
},
{
name: 'Peru',
id:8
}
]
}
];
}
myApp.directive("collection", collection);
function collection() {
return {
restrict: "E",
replace: true,
scope: {
collection: '=',
nextName: '='
},
template:
'<div id="{{nextName}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="">'+
'<div class="panel-body">'+
'<member ng-repeat="member in collection" member="member"></member>'
};
}
myApp.directive("member", ['$compile', member]);
function member($compile) {
return {
restrict: "E",
replace: true,
scope: {
member: '='
},
template:
'<div class="panel panel-default">'+
'<div class="panel-heading" role="tab" id="{{member.id}}">'+
'<h4 class="panel-title">'+
'<a data-toggle="collapse" href="#{{member.name}}" aria-expanded="true">'+
'{{member.name}} <span> {{member.money}} </span> '+
'</a>'+
'</h4>'+
'</div>',
link: function (scope, element, attrs) {
if (angular.isArray(scope.member.children)) {
$compile('<collection next-name="member.name" collection="member.children"></collection>')(scope,
function(cloned, scope){
element.append(cloned);
}
);
}
}
}
}
</script>
</body>
</html>