-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
544 lines (536 loc) · 19.7 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AngularJs</title>
<link rel="icon" href="src/img/favicon.ico">
<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-csp.css">
<link rel="stylesheet" href="node_modules/icheck/skins/flat/blue.css" >
<link rel="stylesheet" type="text/css" href="src/css/angular-nl.css">
<link rel="stylesheet" type="text/css" href="libs/jedate/skin/jedate.css">
<link rel="stylesheet" type="text/css" href="node_modules/angular-ui-grid/ui-grid.min.css" />
<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="node_modules//bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="node_modules/angular-ui-router/release/angular-ui-router.min.js"></script>
<script type="text/javascript" src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>
<script type="text/javascript" src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" src="node_modules/icheck/icheck.min.js"></script>
<script type="text/javascript" src="node_modules/echarts/dist/echarts.min.js"></script>
<script type="text/javascript" src="src/directive/nl-echarts/nl-echarts.js"></script>
<script type="text/javascript" src="libs/jedate/jquery.jedate.min.js"></script>
<script type="text/javascript" src="src/directive/nl-icheck/nl-icheck.js"></script>
<script type="text/javascript" src="src/service/myService.js"></script>
<script src="node_modules/angular-ui-grid/ui-grid.min.js"></script>
<style type="text/css">
body{overflow-y: scroll;}
.clearfix{ zoom:1;}no
.clearfix:after{ content:''; display:block; clear:both;}
ul,li{list-style: none;padding:0;margin:0;}
#viewContainer,#navcontainer{width: 80%;margin:0 auto;}
.innerCtr{background-color: #3598db;padding:20px;box-sizing: border-box;margin:10px 0;color:#333;border-radius: 3px}
.cellYellow{background-color:yellow !important;color:red;}
.cellInfo{background-color: #20a0ff;}
.cellRed{background-color: #ff4949;}
.cellClass{padding:5px 10px;border-radius: 5px;margin:5px;width:60px;color:#fff;font-size: 12px;cursor: pointer;}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="personCtrl">
<div>
<div id="navcontainer">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grcnpmouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">AngularJS Demo</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li ui-sref-active="active"><a ui-sref="bootstrap">bootstrap</a></li>
<li ui-sref-active="active"><a ui-sref="ngForm">NG-Form</a></li>
<li ui-sref-active="active"><a ui-sref="uiView">路由</a></li>
<li ui-sref-active="active"><a ui-sref="directive">组件篇</a></li>
<li ui-sref-active="active"><a ui-sref="relation">控制器指令通信</a></li>
<!-- <li class="dropdown" ui-sref-active="active">
<a href="#/F8" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">F8 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">镜像</a></li>
<li><a href="#">容器</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">kubernetes</a></li>
</ul>
</li> -->
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a>Layout</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
</div>
<div ui-view id="viewContainer"></div>
</div>
<script>
var BASEURL="http://localhost:3000/";
var app = angular.module('myApp',['ui.router','ui.bootstrap','nlEcharts','nlTabs','nlIcheck','myService','ui.grid','ui.grid.pagination','ui.grid.edit', 'ui.grid.selection','ui.grid.moveColumns','ui.grid.resizeColumns','ui.grid.autoResize','ui.grid.pinning']);
app.controller('personCtrl',['$scope','$location','$uibModal','$http', function($scope,$location,$uibModal,$http) {
$scope.alerts = [];
$scope.addAlert = function () {
$scope.alerts.push({ msg: '这是一条消息!' });
};
$scope.name="我是最外层的控制器数据";
$scope.dat = new Date();
$scope.format = "yyyy/MM/dd";
$scope.altInputFormats = ['yyyy/M!/d!'];
$scope.popup1 = {
opened: false
};
$scope.open1 = function () {
$scope.popup1.opened = true;
};
$scope.modal=null;
$scope.maxSize = 5;
$scope.totalItems = 175;
$scope.currentPage = 1;
var confirmTemplate = ["<h3>我是一个dialaog</h3><button ng-click='closeModal()'>关闭模态框</button>"].join("")
$scope.showModal=function(){
$scope.modal=$uibModal.
open({
scope:$scope,
template:confirmTemplate
})
};
$scope.closeModal=function(){
$scope.modal.close();
}
}]);
//表单控制器
app.controller("formCtrl",['$scope',function($scope){
$scope.userdata = {};
$scope.submitForm = function(){
if($scope.myForm.$invalid){
alert("请检查表单提交信息!");
return false;
}else{
console.log($scope.userdata);
alert("提交成功!")
}
};
$scope.resetForm=function(){
location.reload();
}
}]);
//指令页面的Ctrl
app.controller('directiveCtrl',['$scope','$http','$notice','uiGridConstants',function($scope,$http,$notice, uiGridConstants){
var getPage=function(){
alert(123)
}
$scope.getSelectData=function(){
let selectPersons=$scope.gridApi.selection.getSelectedRows();
selectPersons.forEach(function(item,index){
selectPersons[index].tag=true;
});
};
$scope.gridOptions1 = {
//-------- 选中 ----------------
enableRowSelection: true, //是否可选中行,默认值:true
enableSelectAll: true,//是否可全选
multiSelect:true, // 是否可多选行
enableFullRowSelection : false,//是否点击行任意位置后选中,默认为false,当为true时,checkbox可以显示但是不可选中
enableFooterTotalSelected: false, // 是否显示选中的总数,默认为true, 如果显示,showGridFooter 必须为true
enableRowHeaderSelection : true, //是否显示选中checkbox框 ,默认为true
enableSelectionBatchEvent : false, //默认true
isRowSelectable: function(row){ //GridRow
/*if(row.entity.sex == '女'){
row.grid.api.selection.selectRow(row.entity); // 选中行
}*/
}, //用于初始化显示选中数据
rowHeight:40, //设置行高度
noUnselect: false,//默认false,选中后是否可以取消选中,false表示可以取消选中
//selectionRowHeaderWidth:30 ,//默认30 ,设置选择列的宽度;
//-------- 过滤属性 ----------------
enableFiltering:true, //是否过滤,可以写在columnDefs的单列中
//-------- footer属性 ----------------
showGridFooter: true, //是否显示totalItems
showColumnFooter: true, //是否显示列下最后总结的行,结合uiGridConstants在columnDefs中使用
//-------- 表格头部 ----------------
enableGridMenu: true, //是否显示头部右上侧删选控件
//-------- 表格内是否可编辑 ----------------
enableCellEdit:false,
//-------- 分页属性 ----------------
useCustomPagination: false, //是否使用前台分页,默认值:true;使用后台分页,设置为false
enablePaginationControls: true, //使用显示默认的底部分页
useExternalPagination:true,//是否使用分页按钮,默认值是false
enablePagination: true, //是否分页,默认为true
paginationPageSizes: [10, 15, 30], //每页显示个数可选项
paginationCurrentPage:1, //当前页码
paginationPageSize:30, //每页显示个数
totalItems :236, // 总数量
//paginationTemplate:"<div>我是自定义的分页模板</div>", //自定义底部分页代码
onRegisterApi: function(gridApi) {
$scope.gridApi = gridApi;
//分页按钮事件
$scope.gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
$scope.getGridData();
});
//行选中事件
$scope.gridApi.selection.on.rowSelectionChanged($scope,function(row,event){
//console.log(row.entity);
});
},
columnDefs: [
{ field:'id',
displayName:'身份证号',//显示的名称
enableSorting:false, //是否排序
//pinnedRight:true, //固定右边栏位置
cellClass:'cellYellow', //设置table中此列的样式
//width:300,
cellTooltip: function( row, col ) {
return 'Name: ' + row.entity.name + ' Company: ' + row.entity.company;
},
headerTooltip: function( col ) {
return 'Header: ' + col.displayName;
}
},
{ field:'name',
displayName:'姓名',
enableFiltering: false,
enableCellEdit:true,
//pinnedLeft:true, //固定左边栏位置
//width:100
},
{ field:'sex',
displayName:'性别',
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: [ { value: '男', label: '男' }, { value: '女', label: '女' }]
},
editableCellTemplate: 'ui-grid/dropdownEditor', //可编辑的状态下拉选项
editDropdownValueLabel: 'sex',//可编辑:与editDropdownOptionsArray中key值对应
editDropdownOptionsArray: [
{ id: '男', sex: '男' },
{ id: '女', sex: '女' }
],
//width:60
},
{ field:'age',
displayName:'年龄',
aggregationType: uiGridConstants.aggregationTypes.min,
type: 'number',
//width:60
},
{ field:'company',
displayName:'公司',
footerCellTemplate: '<div class="ui-grid-cell-contents" style="background-color:#ff4949;color: White">custom template</div>',
//width:100
},
{ name: 'edit',
displayName: '兴趣爱好',
cellTemplate: '<button type="button" class="btn btn-primary btn-sm" ng-click="grid.appScope.edit(row.entity)" >点击看到我的兴趣吧</button>',
enableCellEdit:false,
enableFiltering: false,
//width:150
},
{
field:'master',
displayName:'学历',
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: [ { value: '本科', label: '本科' }, { value: '研究生', label: '研究生' },{ value: '大专', label: '大专' },{ value: '博士', label: '博士' }]
},
//width:150
},
{
field:'Tag',
displayName:'是否录用',
//width:100,
enableFiltering: false,
cellTemplate:'<div class="cellClass" ng-click="row.entity.tag=!row.entity.tag" ng-class="{\'cellInfo\':row.entity.tag,\'cellRed\':!row.entity.tag}"><span ng-if=row.entity.tag>录用</span><span ng-if=!row.entity.tag>不录用</span></div>'
}
]
};
$scope.edit=function(val){
alert(val.name + ' 的爱好是:'+val.hobby)
};
$scope.getGridData=function(){
$http({
method:"GET",
url:BASEURL+"gridData"
}).success(function(data,status,headers,config){
$scope.gridOptions1.data=data.message;
}).error(function(data,status,headers,config){
alert(data);
})
};
$scope.getGridData();
$scope.jedateoption={
skinCell:"jedateblue", //日期风格样式,默认蓝色
format:"YYYY-MM-DD hh:mm:ss", //日期格式
minDate:"1900-01-01 00:00:00", //最小日期
maxDate:"2099-12-31 23:59:59", //最大日期
language:{ //多语言设置
name : "cn",
month : ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
weeks : [ "日", "一", "二", "三", "四", "五", "六" ],
times : ["小时","分钟","秒数"],
clear : "清空",
today : "今天",
yes : "确定",
close : "关闭"
},
};
$scope.showNotice=function(option){
$notice.open(option)
}
$scope.name="parentCtrl";
$scope.dream="父亲的梦想考取清华北大";
$scope.showMyFavor=function(fav){
alert(fav)
};
$scope.tabsData=[
{"title":"angualr","content":"google"},
{"title":"vue","content":"尤雨溪"},
{"title":"react","content":"faceBook"}
];
$scope.getTableData=function(){
$http({
method:"GET",
url:BASEURL+"getData"
}).success(function(data,status,headers,config){
$scope.tableDatas=data.message;
}).error(function(data,status,headers,config){
alert(data);
})
};
$scope.getTableData();
}])
app.controller('PaginationDemoCtrl', ['$scope',function ($scope) {
$scope.setPage = function (pageNo) {
$scope.currentPage = pageNo;
};
$scope.changePage = function() {
$scope.getTableData();
};
$scope.maxSize = 5;
$scope.totalItems = 175;
$scope.currentPage = 1;
$scope.itemsPerPage=15;
}]);
//控制器与指令通信关系
app.controller('parentCtrl1',['$scope',function($scope){
$scope.dream1="父亲选的梦想是医生";
$scope.dream2={"dream":"父亲选的梦想是医生"};
}]);
app.controller("childCtrl1",["$scope",function($scope){
}]);
app.controller("parentCtrl2",["$scope",function($scope){
$scope.dream1="父亲选的梦想是dream1";
$scope.dream2={"dream":"父亲选的梦想是dream2"};
$scope.dream3="父亲选的梦想是dream3";
$scope.dream4={"dream":"父亲选的梦想是dream4"}
}]);
app.directive('myDirective',function(){
return{
restrict:"AE",
template:'<ul>\
<li class="childItem">\
1.儿子的梦想是(基本类型) :<input type="text" ng-model="dream1"> scope:false / true</br/>\
</li>\
<li class="childItem">\
2.儿子的梦想是(引用类型) :<input type="text" ng-model="dream2.dream"> scope:false / true</br/>\
</li>\
</ul>'
}
});
app.directive('myDirective1',function(){
return{
restrict:"AE",
scope:{},
template:'<ul>\
<li class="childItem">\
3.儿子的梦想是(基本类型) :<input type="text" ng-model="dream1"> scope:{}</br/>\
</li>\
<li class="childItem">\
4.儿子的梦想是(引用类型) :<input type="text" ng-model="dream2.dream"> scope:{}</br/>\
</li>\
</ul>'
}
});
app.directive('myDirective2',function(){
return{
restrict:"AE",
scope:{
dream3:"=",
dream4:"="
},
template:'<ul>\
<li class="childItem">\
5.儿子的梦想是(基本类型) :<input type="text" ng-model="dream3"> scope:{dream3:"="}</br/>\
</li>\
<li class="childItem">\
6.儿子的梦想是(引用类型) :<input type="text" ng-model="dream4.dream"> scope:{dream4:"="}</br/>\
</li>\
</ul>'
}
});
app.controller('parentCtrl3',['$scope',function($scope){
$scope.$on('emitParentCtrl1', function(e, hobby) {
$scope.hobby1 = hobby;
});
// $scope.hobby2={"hobby":""};
$scope.$on('emitParentCtrl2', function(e, hobby) {
$scope.hobby2=hobby;
});
}]);
app.controller('childCtrl3',['$scope',function($scope){
$scope.hobby1="码代码";
$scope.hobby2={"hobby":"写前端"};
$scope.emitParentCtrl1=function(){
$scope.$emit('emitParentCtrl1', $scope.hobby1);
};
$scope.emitParentCtrl2=function(){
$scope.$emit('emitParentCtrl2', $scope.hobby2);
};
}]);
app.controller("parentCtrl4",['$scope',function($scope){
$scope.hobby1="钓鱼哎";
$scope.hobby2={'hobby':"旅游了哎"};
$scope.broadcastChild1=function(){
$scope.$broadcast('broadcastChild1',$scope.hobby1);
};
$scope.broadcastChild2=function(){
$scope.$broadcast('broadcastChild2',$scope.hobby2);
}
}]);
app.controller("childCtrl4",['$scope',function($scope){
$scope.hobby1="";
$scope.hobby2=null;
$scope.$on('broadcastChild1',function(e,hobby){
$scope.hobby1=hobby;
});
$scope.$on('broadcastChild2',function(e,hobby){
$scope.hobby2=hobby;
})
}]);
//echarsController
app.controller('echartsController',['$scope','$http',function($scope,$http){
function onClick(params){
console.log(params);
};
$scope.lineConfig = {
theme:'default',
event: [{click:onClick}],
dataLoaded:true
};
$scope.lineOption1 = {
tooltip: {},
legend: {
data:['销量']
},
xAxis: {
data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'bar'
}]
};
$scope.lineOption2 = {
tooltip: {},
legend: {
data:['销量']
},
xAxis: {
data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
roseType: 'radius',
label: {
normal: {
textStyle: {
color: 'rgba(255, 255, 255, 0.3)'
}
}
},
labelLine: {
normal: {
lineStyle: {
color: 'rgba(255, 255, 255, 0.3)'
},
smooth: 0.2,
length: 10,
length2: 20
}
},
name: '销量',
type: 'pie'
}]
};
$scope.lineOption3 = {
tooltip: {},
legend: {
data:['销量']
},
xAxis: {
data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'line'
}]
};
$scope.refreshChart=function(){
getEchartsData();
};
function getEchartsData(){
$http({
method:"GET",
url:BASEURL+"echartsData"
}).success(function(data,status,headers,config){
$scope.lineOption1.series[0].data=data.message;
$scope.lineOption2.series[0].data=data.message;
$scope.lineOption3.series[0].data=data.message;
}).error(function(data,status,headers,config){
alert(data);
})
};
getEchartsData();
}]);
app.directive('nlJedate',function(){
return{
restrict:"EA",
scope:{
option:"=nlJedateoption"
},
link:function(scope,ele,attrs,require){
ele.jeDate(scope.option);
}
}
});
// 路由页面控制器
app.controller('viewController',['$scope','$state',function($scope,$state){
$scope.goToNg=function(){
$state.go('uiView.ng',{id:'我是通过$state.go()传递的参数'})
}
}]);
app.controller('ngController',['$scope','$stateParams',function($scope,$stateParams){
$scope.Id=$stateParams.id;
}])
</script>
<script type="text/javascript" src="src/js/route.js"></script>
<script type="text/javascript" src="src/directive/nl-tab/nl-tabs.js"></script>
</body>
</html>