13、angular1之分页组件(包含勾选、过滤、请求服务)、laydate、购物车、两种根绑定、函数两种传递、首页index.html、全局方法、五种服务、过滤、重要指令(ng-)、单选框|复选框|下拉框三者联合案例、子组件向父组件传值、directive自定义标签、获取不到新value、多种forEach、ui.router、jqLite的API参考(2300行)

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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
一、angular1之分页组件(包含勾选、过滤、请求服务)
<!DOCTYPE html>
<html lang="en" ng-app="myModel">
<head>
  <meta charset="UTF-8">
  <title>分页组件之angular1.6.2版</title>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  <style>
    .simpleDialog {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .simpleDialog .mask {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: black;
      opacity: 0.5;
    }
    .simpleDialog .content {
      position: fixed;
      background: white;
      opacity: 1;
      display: flex;
      flex-direction: column;
    }
    .simpleDialog .content .title {
      display: flex;
      background: blue;
      color: white;
      padding: 10px;
      cursor: pointer;
    }
    .simpleDialog .content .title .titleText {
      flex: 1;
    }
    .simpleDialog .content .title .titleCross {
      width: 10px;
      padding: 0 5px;
    }
    .simpleDialog .content .tip {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .simpleDialog .content .conform {
      display: flex;
      justify-content: center;
      padding: 10px;
      background: blue;
    }
    .complexDialog {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .complexDialog .mask {
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: black;
      opacity: 0.5;
    }
    .complexDialog .content {
      position: fixed;
      background: white;
      opacity: 1;
      display: flex;
      flex-direction: column;
    }
    .complexDialog .content .title {
      display: flex;
      background: blue;
      color: white;
      padding: 10px;
      cursor: pointer;
    }
    .complexDialog .content .title .titleText {
      flex: 1;
    }
    .complexDialog .content .title .titleCross {
      width: 10px;
      padding: 0 5px;
    }
    .complexDialog .content .tip {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .complexDialog .content .conform {
      display: flex;
      justify-content: center;
      padding: 10px;
      background: blue;
    }
    table {
      border-collapse: collapse;
      border: 1px solid #cbcbcb;
    }
    table td,
    table th {
      padding: 5px;
      border: 1px solid #cbcbcb;
    }
    table thead {
      background-color: #e0e0e0;
      color: #000;
      text-align: left;
    }
    .filter {
      width: 998px;
      border: 1px solid gray;
      padding: 10px 0px;
    }
    .filter .line {
      display: flex;
    }
    .filter .line .group {
      width: 330px;
    }
    .filter .line .group .label {
      display: inline-block;
      width: 120px;
      height: 24px;
      line-height: 24px;
      text-align: right;
    }
    .filter .line .group .input {
      display: inline-block;
      width: 180px;
      height: 24px;
      line-height: 24px;
      border-radius: 3px;
    }
    .filter .line .group .select {
      display: inline-block;
      width: 188px;
      height: 26px;
      line-height: 26x;
      border-radius: 3px;
    }
    .wholeCircle {
      position: fixed;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      background: rgb(145, 138, 138);
      opacity: 0.5;
      z-index: 100;
      user-select: none;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .wholeCircle .content {
      background: #fff;
      border-radius: 5px;
      overflow: hidden;
      z-index: 101;
      box-shadow: 5px 2px 6px #000;
      width: 100px;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    @keyframes customCircle {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(-360deg);
      }
    }
    .circle {
      animation: customCircle 1s infinite linear;
    }
  </style>
</head>
<body>
  <div ng-controller="thisCtrl">
    <div>
      <div style="padding: 5px 0; color: red">
        <button
          style="color: red"
          ng-click="divideDatas.getResultOfCheckAndFilter(divideDatas.isShowFilter,divideDatas.isUseFilter,divideDatas.filterOptions)"
        >
          获取勾选和过滤结果
        </button>
        <span ng-bind="divideDatas.toServerDatas"></span>
      </div>
      <div style="padding-bottom: 5px">
        <img
          src="{{checkDatas.stateAllPages&&checkDatas.allExcludedIds.length===0?checkImg.yes:checkImg.no}}"
          ng-click="checkDatas.clickAllPages(divideDatas.tableDatas)"
        />
        <span ng-bind="checkDatas.textAllPages"></span>
      </div>
      <div style="padding-bottom: 5px">
        <button ng-click="divideDatas.toggleShowFilter()">
          {{divideDatas.isShowFilter?'关闭过滤':'使用过滤'}}
        </button>
        <button ng-click="divideDatas.emptyFilterOptions({value5:'已读后台'})">
          清空过滤
        </button>
        <button ng-click="divideDatas.request(1)">刷新</button>
      </div>
      <div
        style="margin-bottom: 5px"
        class="filter"
        ng-show="divideDatas.isShowFilter"
      >
        <div class="line">
          <div class="group">
            <label class="label">标签</label>
            <input
              class="input"
              type="text"
              ng-model="divideDatas.filterOptions.value1"
            />
          </div>
          <div class="group">
            <label class="label">这就是长标签</label>
            <input
              class="input"
              type="text"
              ng-model="divideDatas.filterOptions.value2"
            />
          </div>
          <div class="group">
            <label class="label">标签</label>
            <input
              class="input"
              type="text"
              ng-model="divideDatas.filterOptions.value3"
            />
          </div>
        </div>
        <div class="line" style="padding-top: 10px">
          <div class="group">
            <label class="label">这就是长标签</label>
            <input
              class="input"
              type="text"
              ng-model="divideDatas.filterOptions.value4"
            />
          </div>
          <div class="group">
            <label class="label">下拉框</label>
            <select
              class="select"
              ng-model="divideDatas.filterOptions.value5"
              ng-options="item.back as item.front for item in resultDo"
            ></select>
          </div>
          <div class="group">
            <label class="label"></label>
            <button
              style="width: 188px; height: 28px"
              ng-click="divideDatas.useFilter()"
            >
              过滤
            </button>
          </div>
        </div>
      </div>
      <table style="width: 1000px">
        <thead>
          <tr>
            <th>
              <img
                src="{{checkDatas.stateThisPage?checkImg.yes:checkImg.no}}"
                ng-click="checkDatas.clickThisPage(divideDatas.tableDatas,divideDatas.allItemsNum)"
              />
            </th>
            <th>序号</th>
            <th>数据1</th>
            <th>数据2</th>
            <th>数据3</th>
            <th>数据4</th>
            <th>数据5</th>
            <th>数据6</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="data in divideDatas.tableDatas track by $index">
            <td>
              <img
                src="{{data.state?checkImg.yes:checkImg.no}}"
                ng-click="checkDatas.clickSingleItem(data,divideDatas.tableDatas,divideDatas.allItemsNum)"
              />
            </td>
            <td ng-bind="(divideDatas.nowPageNum-1)*10 + ($index+1)"></td>
            <td ng-bind="data.key1"></td>
            <td ng-bind="data.key2"></td>
            <td ng-bind="data.key3"></td>
            <td ng-bind="data.key4"></td>
            <td ng-bind="data.key5"></td>
            <td ng-bind="data.key6"></td>
          </tr>
        </tbody>
      </table>
      <divide-page
        divide-datas="divideDatas"
        check-datas="checkDatas"
      ></divide-page>
    </div>
  </div>
</body>
<script>
  var app = angular.module('myModel', []);
  app.controller('thisCtrl', function ($scope,checkImg) {
    $scope.modelData = {
      value: 5
    };
    $scope.change = function (value) {
      console.log(value);
    };
    $scope.submit = function () {
      console.log('此处向后台发送请求');
    };
    $scope.requiredDataSimple = {
      simpleDialogTitleId: 'wholeTitleId',
      simpleDialogContentId: 'wholeContentId'
    };
    $scope.clickButtonSimple = function () {
      $scope.requiredDataSimple.isShow = true;
      $scope.requiredDataSimple.width = '600px';
      $scope.requiredDataSimple.title = '详情';
      $scope.requiredDataSimple.tip = '提交失败';
      $scope.requiredDataSimple.zIndex = 10;
    };
    $scope.requiredDataComplex = {
      complexDialogTitleId: 'wholeTitleId1',
      complexDialogContentId: 'wholeContentId1'
    };
    $scope.clickButtonComplex = function () {
      $scope.requiredDataComplex.isShow = true;
      $scope.requiredDataComplex.width = '1060px';
      $scope.requiredDataComplex.height = '700px';
      $scope.requiredDataComplex.title = '详情';
      $scope.requiredDataComplex.zIndex = 10;
      $scope.requiredDataComplex.cancel = function () {
        console.log('cancel');
      };
    };
    $scope.checkImg = checkImg;
    //<part-circle is-show='thisCircle'></part-circle>
    $scope.thisCircle = { isShow : false };
    $scope.array=[true,true,true,true,true];
    $scope.divideDatas = {
      //1、请求配置1(路由和方式)
      url: '',
      method: 'post',
      //2、请求配置2(请求参数的key,前端通过这个配置,发送数据给后台)
      nowPageNumToServer:'nowPageNumToServer', //发送给后台的当前页码key
      allPagesNumToServer:'allPagesNumToServer', //发送给后台的所有页页数key
      allItemsNumToServer:'allItemsNumToServer', //发送给后台的所有页数据数key
      eachPageItemsNumToServer:'eachPageItemsNumToServer', //发送给后台的每页最多数据数key
      //3、响应配置(返回数据的key,前端通过这个配置,获取后台的数据)
      nowPageNumFromServer: 'nowPageNumFromServer', //来自服务器的当前页码key
      allPagesNumFromServer:'allPagesNumFromServer', //来自服务器的所有页页数key
      allItemsNumFromServer:'allItemsNumFromServer', //来自服务器的所有页数据数key
      eachPageItemsNumFromServer:'eachPageItemsNumFromServer', //来自服务器的每页最多数据数key
      tableDatasKey: 'tableDatasArray', //来自服务器的表格数据key
      //4、分页初始化配置(分页在本页面首次渲染时,使用该数据)
      nowPageNum: 0, //当前页数
      allPagesNum: 0, //所有页数
      allItemsNum: 0, //所有页所有条目数
      eachPageItemsNum: 10, //每页展示条目数
      //5、初始化以下数据,供页面使用(前端根据需要决定,不受后台影响)
      dataOrParams: 'data', //参数放在哪个配置下,只有data和Params两个选择
      extraParams: {}, //页码、页条目数、过滤条件外的参数,调用divideDatas.request函数,重新渲染页面。
      filterOptions: {}, //过滤条件
      isShowFilter: false, //是否显示过滤条件。有时默认false时,显示一部分过滤条件,点击“展开”后,显示剩余过滤条件
      isUseFilter: false, //是否使用过滤条件。点击过滤后,才使用过滤条件。
      isAbandonInit: false, //是否放弃初始化组件
      partCircle: false, //把当前页控制局部转圈隐现的变量告诉cyRequest
      isUsePartCircle: false, //是否使用局部转圈
      isUseOneCircle: false, //是否使用单个全局转圈
      isUseManyCircle: false, //是否使用多个全局转圈
      frontMoreText:  '', //('文字 ')或者("文字 "+result.numOne+" 文字 "),
      totalText: '共', //,
      totalUnit: '条', //总数据的单位
      backMoreText: '', //(' 文字')或者("文字 "+result.numThree+" 文字"),
      //6、以下是现成方法,调用即可
      //过滤条件打开或关闭时执行的函数
    };
    $scope.resultDo = [
      { front: '全部前端', back: '全部后台' },
      { front: '已读前端', back: '已读后台' },
      { front: '未读前端', back: '未读后台' }
    ];
    $scope.divideDatas.filterOptions.value5 = '已读后台';
  });
  app.factory('checkImg', function () {
    return {
      yes:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAA+UlEQVQoFZWSMU4DMRBF/584G7QSRcIxuAZKEykNEiUVHVTQRaKh4AIcgAvQpkukVDlBOAYNSGSlXXuwpViyYYFdS9aMZ/6bsezh5HZ3T2KhqkfosEhWqnjkyd1u3xWKdQMsfaEAB0Zilf8swfdU0w0klmpGpz1BvpbHcklbPf8Okts0CfJtWBTz/Yc++Jc8S3PZVQfKGwiuvMD6XYsMzm1dT/1jXKdQ8E0asHRrAzOzbC6UGINWHPQp1UQ/6wjF2LpmJSKfhti4Bi8+lhWP4I+gAqV1uqSi8j9WRuF3m3eMWVUJBeKxzUoYn7bEX7HDyPmB7QEHbRjyL+/+VnuXDUFOAAAAAElFTkSuQmCC',
      no:
        'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAAbklEQVQoFWM8c+ZMLQMDQxUQcwAxMeAHUFEbC5CoYmNj02ZmZn5FjK6/f/+K/fr16ypIIwdIk7a29hdiNF69ehWkjIOJGMXY1IxqxBYqULEhFDiglPMDlIygKQKPryBSILUgPSCNbaC0B6RJSuQAbowizhJuOsAAAAAASUVORK5CYII='
    };
  });
  app.factory('cyRequest', function ($http, wholeCircle) {
    function thisHttp(clientDatas, deferred) {
      var toServerDatas = {
        method: clientDatas.method,
        url: clientDatas.url
      };
      var dataOrParams = clientDatas.dataOrParams || 'data';
      toServerDatas[dataOrParams] = clientDatas.AllParams;
      if (clientDatas.responseType) {
        toServerDatas.responseType = clientDatas.responseType;
      }
      if (clientDatas.isUsePartCircle) {
        clientDatas.partCircle.isShow = true;
      }
      if (clientDatas.isUseOneCircle) {
        wholeCircle.isShow = true;
      }
      if (clientDatas.isUseManyCircle) {
        wholeCircle.isShow = true;
      }
      $http(toServerDatas)
        .then(function (result) {
          //result.status(不是result.clientDatas.status)===200时进入这里,否则进入catch
          if (clientDatas.isDirectUseDatas) {
            deferred.resolve(result);
            //如果出错就一直转圈,那么可以把finally里的代码放到这里
          } else {
            if (result.clientDatas.status === 1000) {
              //全局弹窗告知结果
            } else if (result.clientDatas.status === 0) {
              //全局弹窗告知结果
            } else {
              deferred.resolve(result.clientDatas);
              //如果出错就一直转圈,那么可以把finally里的代码放到这里
            }
          }
        })
        .catch(function (err) {
          deferred.reject(err);
        })
        .finally(function () {
          if (clientDatas.isUsePartCircle) {
            clientDatas.partCircle.isShow = false;
          }
          if (clientDatas.isUseOneCircle) {
            wholeCircle.isShow = false;
          }
          if (clientDatas.isUseManyCircle) {
            // $scope.array=[true,true,true,true,true];
            // wholeCircle: {
            //   array: $scope.array,
            //   index: 0
            // },
            var flag = false;
            clientDatas.wholeCircle.array[clientDatas.wholeCircle.index]=false;
            for(var i=0; i<clientDatas.wholeCircle.array.length; i++){
              if(clientDatas.wholeCircle.array[i]) flag = true
            }
            if(!flag) wholeCircle.isShow = false;
          }
        });
    }
    return function (clientDatas) {
      var deferred = $q.defer();
      if (clientDatas.warn) {
        //全局弹窗告知结果
        $scope.requiredData = {
          isShow: true,
          width: '400px',
          title: '详情',
          tip: '确认提交',
          submit: function () {
            thisHttp(clientDatas, deferred);
          }
        };
      } else {
        thisHttp(clientDatas, deferred);
      }
      return deferred.promise;
    };
 
    // $scope.array=[true,true,true,true,true];
    // cyRequest({
    //   method: 'post',
    //   url: 'a/b/c',
    //   warn: '确定提交吗?',
    //   dataOrParams: 'data',
    //   AllParams: {key:1},
    //   partCircle: $scope.thisCircle,//把当前页控制局部转圈隐现的变量告诉cyRequest
    //   isUsePartCircle: true,//是否使用局部转圈
    //   isUseOneCircle: true,//是否一个请求使用一个全局转圈
    //   isUseManyCircle: true,//是否多个请求共用一个全局转圈
    //   wholeCircle: {//多个请求共用一个全局转圈
    //     array: $scope.array,
    //     index: 0
    //   },
    // })
  });
  app.directive('dividePage', function () {
    var html = `
      <div ng-show="divideDatas.allPagesNum>=1" style="display:flex;width:1000px;margin-top:20px;">
        <div>
          <div>
            <button
              ng-hide="divideDatas.allPagesNum<=10"
              ng-click="clickDividePage('front') "
              ng-disabled="divideDatas.nowPageNum===1"
            >上一页</button>
            <button
              ng-repeat="num in divideArray track by $index"
              ng-bind="num"
              ng-click="clickDividePage(num) "
              ng-style="num===divideDatas.nowPageNum?{ 'color':'red'}:{'color':'black'}"
              ng-disabled="num==='...'"
              style="margin:0 3px;"
            >
            </button>
            <button
              ng-hide="divideDatas.allPagesNum<=10"
              ng-click="clickDividePage('back') " 
              ng-disabled="divideDatas.nowPageNum===divideDatas.allPagesNum"
            >下一页</button>
          </div>
           
        </div>
        <div style="display:flex; flex:1; justify-content:flex-end;">
          <div style="margin-right:20px;">
            <span>转到第</span>
            <input type="text" ng-model="customString" ng-keydown="clickDividePage('leap',$event)" style="width:30px;">
            <span>页</span>
            <button ng-click="clickDividePage('leap',{which:13})">Go</button>
          </div>
          <div>
            <span>每页显示</span>
            <select ng-model="divideDatas.eachPageItemsNum" ng-options="item.back as item.front for item in numOptions" ng-disabled="true"></select>
            <span>条,</span>
          </div>
          <div>
            <span ng-bind="divideDatas.frontMoreText"></span>
            <span ng-bind="divideDatas.totalText"></span>
            <span ng-bind="divideDatas.allItemsNum"></span>
            <span ng-bind="divideDatas.totalUnit"></span>
            <span ng-bind="divideDatas.backMoreText"></span>
          </div>
        </div>  
      </div>
    `;
    return {
      restrict: 'E',
      template: html,
      scope: {
        divideDatas: '=divideDatas',
        checkDatas: '=checkDatas'
      },
      controller: function ($scope, $timeout /* , cyRequest */) {
        $scope.checkDatas = $scope.checkDatas||{};
        $scope.divideDatas = $scope.divideDatas||{};
        $scope.checkDatas.idKey = $scope.checkDatas.idKey||'id', //每条数据的唯一标志
        $scope.checkDatas.stateThisPage = $scope.checkDatas.stateThisPage||false, //当前页所有项是否全选
        $scope.checkDatas.allIncludedIds = $scope.checkDatas.allIncludedIds||[], //所有被选中数据的ID构成的数组
        $scope.checkDatas.allExcludedIds = $scope.checkDatas.allExcludedIds||[], //所有没被选中数据的ID构成的数组
        $scope.checkDatas.textAllPages = $scope.checkDatas.textAllPages||'全选未启用,没有选择任何项!', //复选框被点击后的提示文字。
        $scope.checkDatas.stateAllPages = $scope.checkDatas.stateAllPages||false, //复选框被点击后的提示文字。
        $scope.checkDatas.isAbandonChecklist = $scope.checkDatas.isAbandonChecklist||false,
        $scope.request = $scope.divideDatas.request = function (pageNum) {
          var AllParams = $scope.getResultOfCheckAndFilter(
            $scope.divideDatas.isShowFilter,
            $scope.divideDatas.isUseFilter,
            $scope.divideDatas.filterOptions,
            $scope.divideDatas.extraParams,
          );
          AllParams.nowPageNum = pageNum;
          // cyRequest({
          //   url: $scope.divideDatas.url,
          //   method: $scope.divideDatas.method,
          //   dataOrParams: $scope.divideDatas.dataOrParams,
          //   AllParams: AllParams,
          //   partCircle: $scope.divideDatas.partCircle,
          //   isUsePartCircle: $scope.divideDatas.isUsePartCircle,
          //   isUseOneCircle: $scope.divideDatas.isUseOneCircle,
          //   isUseManyCircle: $scope.divideDatas.isUseManyCircle,
          // }).then(function () {
          var data = [];
          for (var i = 1; i <= 144; i++) {
            var obj = {
              id: 'id' + i,
              key1: '数据' + (i + 0),
              key2: '数据' + (i + 1),
              key3: '数据' + (i + 2),
              key4: '数据' + (i + 3),
              key5: '数据' + (i + 4),
              key6: '数据' + (i + 5),
              key7: '数据' + (i + 6)
            };
            data.push(obj);
          }
          var result = {
            tableDatasArray: [],
            nowPageNumFromServer: 5,
            allPagesNumFromServer: 15,
            allItemsNumFromServer: 144,
            eachPageItemsNumFromServer: 10
          };
          result.tableDatasArray = data.slice(
            (pageNum - 1) * 10,
            pageNum * 10
          );
          $scope.customString =
            pageNum || result[$scope.divideDatas.nowPageNumFromServer];
          $scope.divideDatas.nowPageNum =
            pageNum || result[$scope.divideDatas.nowPageNumFromServer];
          $scope.divideDatas.allPagesNum =
            result[$scope.divideDatas.allPagesNumFromServer];
          $scope.divideDatas.allItemsNum =
            result[$scope.divideDatas.allItemsNumFromServer];
          $scope.divideDatas.eachPageItemsNum =
            result[$scope.divideDatas.eachPageItemsNumFromServer];
          $scope.divideDatas.tableDatas =
            result[$scope.divideDatas.tableDatasKey];
          if(angular.isFunction($scope.divideDatas.executeOnceBefore)){
            $scope.divideDatas.executeOnceBefore($scope.divideDatas.tableDatas);
            $scope.divideDatas.executeOnceBefore = null;
          }
          if(angular.isFunction($scope.divideDatas.executeEveryTrue)){
            $scope.divideDatas.executeEveryTrue($scope.divideDatas.tableDatas);
          }
          if(angular.isFunction($scope.divideDatas.executeOnceAfter)){
            $scope.divideDatas.executeOnceAfter($scope.divideDatas.tableDatas);
            $scope.divideDatas.executeOnceAfter = null;
          }
          if ($scope.checkDatas) {
            if(!$scope.checkDatas.isAbandonChecklist){
              $scope.checkDatas.signCheckbox($scope.divideDatas.tableDatas);
            }else{
              $scope.checkDatas.init();
            }
          }
          $scope.createDividePage();
          // }).catch(function(){
          //   if (angular.isFunction($scope.divideDatas.executeEveryError)) {
          //     $scope.divideDatas.executeEveryError(result);
          //   }
          // })
        };
        $scope.numOptions = [
          { back: 10, front: 10 },
          { back: 20, front: 20 },
          { back: 30, front: 30 },
          { back: 40, front: 40 },
          { back: 50, front: 50 }
        ];
        $scope.getResultOfCheckAndFilter = $scope.divideDatas.getResultOfCheckAndFilter = function (
          isShowFilter,
          isUseFilter,
          filterOptions,
          extraParams
        ) {
          var checkboxDatas;
          var toServerDatas;
          extraParams = extraParams||{};
          if (!$scope.checkDatas.stateAllPages) {
            if ($scope.checkDatas.allIncludedIds.length === 0) {
              //return 弹窗告知:没有勾选项
            }
            checkboxDatas = {
              isSelectAll: false,
              allIncludedIds: $scope.checkDatas.allIncludedIds
            };
          } else {
            checkboxDatas = {
              isSelectAll: true,
              allExcludedIds: $scope.checkDatas.allExcludedIds
            };
          }
          if (isShowFilter||isUseFilter) {
            toServerDatas = angular.merge(
              {},
              { checkboxDatas: checkboxDatas },
              { filterOptions: filterOptions },
              extraParams
            );
          } else {
            toServerDatas = angular.merge({}, { checkboxDatas: checkboxDatas }, extraParams);
          }
          this.toServerDatas = toServerDatas; //这行代码在实际项目中不需要
          return toServerDatas;
        };
        $scope.createDividePage = function () {
          var divideArray = [];
          var allPagesNum = $scope.divideDatas.allPagesNum;
          var nowPageNum = $scope.divideDatas.nowPageNum;
          console.log( allPagesNum    )
          console.log( nowPageNum    )
          if (allPagesNum >= 1 && allPagesNum <= 10) {
            for (var i = 1; i <= allPagesNum; i++) {
              divideArray.push(i);
            }
          } else if (allPagesNum >= 11) {
            if (nowPageNum > 6) {
              divideArray.push(1);
              divideArray.push(2);
              divideArray.push(3);
              divideArray.push('...');
              divideArray.push(nowPageNum - 1);
              divideArray.push(nowPageNum);
            } else {
              for (i = 1; i <= nowPageNum; i++) {
                divideArray.push(i);
              }
            }
            // 以上当前页的左边,以下当前页的右边
            if (allPagesNum - nowPageNum >= 6) {
              divideArray.push(nowPageNum + 1);
              divideArray.push(nowPageNum + 2);
              divideArray.push('...');
              divideArray.push(allPagesNum - 2);
              divideArray.push(allPagesNum - 1);
              divideArray.push(allPagesNum);
            } else {
              for (var i = nowPageNum + 1; i <= allPagesNum; i++) {
                divideArray.push(i);
              }
            }
          }
          $scope.divideArray = divideArray;
        };
        $scope.clickDividePage = function (stringOfNum, event) {
          var allPagesNum = $scope.divideDatas.allPagesNum;
          var nowPageNum = $scope.divideDatas.nowPageNum;
          if (stringOfNum === 'front' && nowPageNum != 1) {
            nowPageNum--;
          } else if (stringOfNum === 'back' && nowPageNum != allPagesNum) {
            nowPageNum++;
          } else if (stringOfNum === 'leap') {
            if (event.which != 13) return; //不拦截情形:(1)聚焦输入框、按“Enter”键时;(2)点击“GO”时
            var customNum = Math.ceil(parseFloat($scope.customString));
            if (customNum < 1 || customNum == 'NaN') {
              nowPageNum = 1; //不给提示
            } else if (customNum > allPagesNum) {
              nowPageNum = allPagesNum; //不给提示
            } else {
              nowPageNum = customNum;
            }
          } else {
            nowPageNum = Math.ceil(parseFloat(stringOfNum));
          }
          $scope.customString = nowPageNum;
          $scope.request(nowPageNum);
        };
        $scope.checkDatas.init = function () {
          //点击“刷新”、“过滤”、“清除过滤”时执行
          this.idKey = idKey ? idKey : 'id';
          this.allIncludedIds = [];
          this.allExcludedIds = [];
          this.textAllPages = '全选未启用,没有选择任何项!';
          this.stateAllPages = false;
          this.stateThisPage = false;
        };
        $scope.checkDatas.clickAllPages = function (itemArray) {
          //所有页所有条目全选复选框被点击时执行的函数
          if (this.stateAllPages) {
            if (this.allExcludedIds.length > 0) {
              this.stateAllPages = true;
              this.stateThisPage = true;
              this.textAllPages = '全选已启用,没有排除任何项!';
              angular.forEach(itemArray, function (item) {
                item.state = true;
              });
            } else if (this.allExcludedIds.length == 0) {
              this.stateAllPages = false;
              this.stateThisPage = false;
              this.textAllPages = '全选未启用,没有选择任何项!';
              angular.forEach(itemArray, function (item) {
                item.state = false;
              });
            }
          } else {
            this.stateAllPages = true;
            this.stateThisPage = true;
            this.textAllPages = '全选已启用,没有排除任何项!';
            angular.forEach(itemArray, function (item) {
              item.state = true;
            });
          }
          this.allExcludedIds = [];
          this.allIncludedIds = [];
        };
        $scope.checkDatas.clickThisPage = function (itemsArray, allItemsNum) {
          //当前页所有条目全选复选框被点击时执行的函数
          var that = this;
          this.stateThisPage = !this.stateThisPage;
          angular.forEach(itemsArray, function (item) {
            item.state = that.stateThisPage;
            if (item.state) {
              that.delID(item[that.idKey], that.allExcludedIds);
              that.addID(item[that.idKey], that.allIncludedIds);
            } else {
              that.delID(item[that.idKey], that.allIncludedIds);
              that.addID(item[that.idKey], that.allExcludedIds);
            }
          });
          if (this.stateAllPages) {
            if (this.stateThisPage && this.allExcludedIds.length === 0) {
              this.textAllPages = '全选已启用,没有排除任何项!';
            } else {
              this.textAllPages =
                '全选已启用,已排除' +
                this.allExcludedIds.length +
                '项!排除项的ID为:' +
                this.allExcludedIds;
            }
          } else {
            if (!this.stateThisPage && this.allIncludedIds.length === 0) {
              this.textAllPages = '全选未启用,没有选择任何项!';
            } else {
              this.textAllPages =
                '全选未启用,已选择' +
                this.allIncludedIds.length +
                '项!选择项的ID为:' +
                this.allIncludedIds;
            }
          }
        };
        $scope.checkDatas.clickSingleItem = function (item, itemsArray, allItemsNum) {
          //当前页单个条目复选框被点击时执行的函数
          var that = this;
          item.state = !item.state;
          if (item.state) {
            this.stateThisPage = true;
            this.addID(item[this.idKey], this.allIncludedIds);
            this.delID(item[this.idKey], this.allExcludedIds);
            angular.forEach(itemsArray, function (item) {
              if (!item.state) {
                that.stateThisPage = false;
              }
            });
          } else {
            this.stateThisPage = false;
            this.addID(item[this.idKey], this.allExcludedIds);
            this.delID(item[this.idKey], this.allIncludedIds);
          }
          if (this.stateAllPages) {
            if (this.stateThisPage && this.allExcludedIds.length === 0) {
              this.textAllPages = '全选已启用,没有排除任何项!';
            } else {
              this.textAllPages =
                '全选已启用,已排除' +
                this.allExcludedIds.length +
                '项!排除项的ID为:' +
                this.allExcludedIds;
            }
          } else {
            if (!this.stateThisPage && this.allIncludedIds.length === 0) {
              this.textAllPages = '全选未启用,没有选择任何项!';
            } else {
              this.textAllPages =
                '全选未启用,已选择' +
                this.allIncludedIds.length +
                '项!选择项的ID为:' +
                this.allIncludedIds;
            }
          }
        };
        $scope.checkDatas.signCheckbox = function (itemsArray) {
          //标注当前页被选中的条目,在翻页成功后执行。
          var that = this;
          if (this.stateAllPages) {
            this.stateThisPage = true;
            angular.forEach(itemsArray, function (item) {
              var thisID = item[that.idKey];
              var index = that.allExcludedIds.indexOf(thisID);
              if (index > -1) {
                item.state = false;
                that.stateThisPage = false;
              } else {
                item.state = true;
              }
            });
          } else {
            this.stateThisPage = true;
            angular.forEach(itemsArray, function (item) {
              var thisID = item[that.idKey];
              var index = that.allIncludedIds.indexOf(thisID);
              if (index === -1) {
                item.state = false;
                that.stateThisPage = false;
              }else{
                item.state = true;
              }
            });
          }
        };
        $scope.checkDatas.addID = function (id, idArray) {
          var index = idArray.indexOf(id);
          if (index === -1) {
            idArray.push(id); //如果当前页的单项既有勾选又有非勾选,这时勾选当前页全选,需要这个判断,以免重复添加
          }
        };
        $scope.checkDatas.delID = function (id, idArray) {
          var index = idArray.indexOf(id);
          if (index > -1) {
            idArray.splice(index, 1);
          }
        };
         
        $scope.divideDatas.toggleShowFilter = function () {
          this.isUseFilter = false;
          this.isShowFilter = !this.isShowFilter;
          if (!this.isShowFilter) {
            this.request(1);
          }
        };
        //点击过滤时执行的函数
        $scope.divideDatas.useFilter = function () {
          this.isUseFilter = true;
          this.request(1);
        };
        //清空过滤条件时执行的函数
        //清空选项时,所有值恢复成默认
        $scope.divideDatas.emptyFilterOptions = function () {
          var that = this;
          angular.forEach(that.filterOptions, function (value, key) {
            if(that.filterOptionsInit[key]){
              that.filterOptions[key]= that.filterOptionsInit[key]
            }else{
              that.filterOptions[key] = undefined;
            }
          });
          this.request(1);
        };
        if (!$scope.divideDatas.isAbandonInit) {
          $scope.request(1);
        }
      }
    };
  });
  </script>
</html>
 
 
二、angular1里用laydate.js
1、示例
来源:https://www.layui.com/doc/modules/laydate.html#type
<dir-datepicker date-model="pagin_init.filter_option.beginTime"></dir-datepicker>
(function () {
  angular
    .module('common-dir')
    .directive('dirDatepicker', function () {
      return {
        restrict: 'E',
        template: '<input  type="text" class="form-control common-select-time" ng-model="dateModel"  id="{{dateInputId}}"  style="width:214px" ng-disabled="isDisable" />',
        replace: true,
        scope: {
          format: '@',
          dateModel: '=',
          isDisable: '=',
          callback: '&'
        },
        controller: function ($scope) {
          $scope.dateInputId = 'id' + Math.random();
          angular.element(document).ready(function () {
            var config = {
              elem: '#' + $scope.dateInputId,
              theme: '#007bff',
              trigger: 'click',
              done: function (value) {
                $scope.dateModel = value;
                angular.isFunction($scope.callback) ? $scope.callback() : '';
              }
            };
            if ($scope.format) {
              config.format = $scope.format;//自定义格式
            } else {
              config.type = 'datetime';//控件选择类型
            }
            laydate.render(config);
          });
        },
        link: function () {
        }
      };
    });
})();
laydate.render({
  elem: '#test',
  done: function(value, date, endDate){
    //控件选择完毕后的回调,点击日期、清空、现在、确定均会触发。
    //回调返回三个参数,分别代表:生成的值、日期时间对象、结束的日期时间对象
    console.log(value); //得到日期生成的值,如:2017-08-18
    console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
    console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
  }
});
2、laydate使用详解
laydate.render({
  elem: '#test',
  type:'datetime', // year年选择器,month年月选择器,date年月日选择器,time时间选择器,datetime日期时间选择器
  range: true, //或 range: '~' 来自定义分割字符开启左右面板选择范围
  value: getNowTime(new Date(),true) + "~" + getNowTime(new Date(), false), //'2018-08-18'//必须遵循format参数设定的格式 初始值
  isInitValue: false, //是否允许填充初始值,默认为true
  format: 'yyyy-MM-dd HH:mm:ss', //'yyyy年MM月dd日' //可任意组合  自定义格式
  min: '2017-1-1', //最小范围内的日期时间值
  max: '2017-12-31', //最大范围内的日期时间值
  trigger: 'click', //采用click弹出
  show: true, //直接显示
  closeStop: '#test1', //这里代表的意思是:点击 test1 所在元素阻止关闭事件冒泡。如果不设定,则无法弹出控件
  position: 'static',
  showBottom :false,
  btns: ['clear', 'confirm'],
  lang: 'en', // 'cn'
  theme: 'molv', //主题
  calendar: true, // 是否显示公历
  mark: {
    '0-10-14': '生日',
    '0-12-31': '跨年' //每年12月31日
    '0-0-10': '工资', //每个月10号
    '2017-8-15': '', //具体日期
    '2017-8-20': '预发', //如果为空字符,则默认显示数字+徽章
    '2017-8-21': '发布',
  },
  ready: function(date){
    console.log(date); //控件打开时触发 得到初始的日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0
  },
  change: function (value, date, endDate) { //日期时间选择变化事件
    var nowdate = new Date();
    var enddate = new Date(endDate["year"], endDate["month"] - 1, endDate["date"], endDate["hours"], endDate["minutes"], endDate["seconds"]);
    if (enddate.getTime() > nowdate.getTime()) {
        timescope.hint("不可超出当前日期");
        $(".laydate-btns-confirm").addClass('layui-btn-disabled');
    } else {
        $(".laydate-btns-confirm").removeClass('layui-btn-disabled');
    }
  },
  done: function (value, date, endDate) { //日期选择确认事件
    if (value == "") {
      return;
    }
    // console.log(date, endDate)
    var startdate = new Date(date["year"], date["month"] - 1, date["date"], date["hours"], date["minutes"], date["seconds"]);
    mergestarttime = startdate.getTime();
    var enddate = new Date(endDate["year"], endDate["month"] - 1, endDate["date"], endDate["hours"], endDate["minutes"], endDate["seconds"]);
    mergeendtime = enddate.getTime();
    getflowmerge(name_arrays);
  },
})
3、说明
(1)laydate.js可以通过<html><head><script src="./laydate.js">存在于window.laydate中
(2)在任意一个js文件中,均可以通过console.log(laydate)打印,通过laydate.render(obj)调用
(3)laydate.js不可以通过import "./laydate.js" 获取laydate,这种情形适合于导入自执行函数
(4)laydate.js不可以通过import laydate from "./laydate.js"获取laydate
 
三、agular1购物车
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.1/css/bootstrap.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl" style="margin:20px;" ng-cloak >
  <div>
    <label>全选</label>
    <input type="checkbox" ng-model="allCheck" ng-click="allChecked()">
    <span>总金额:{{ totalValue | currency:"¥"}}</span>
  </div>
  <table class="table table-bordered" ng-repeat="oneShop in allShops track by $index"  ng-init="outerIndex = $index" style="margin:30px auto">
    <thead>
    <tr>
      <th><input type="checkbox" ng-model="oneShop.checked" ng-click="shopChecked(oneShop,allShops)"></th>
      <th colspan="7">{{oneShop.shopName}}</th>
    </tr>
    </thead>
    <tbody>
      <tr ng-repeat="goods in oneShop.shopGoods track by $index"  ng-init="innerIndex = $index">
        <td><input type="checkbox" ng-model="goods.checked" ng-click="goodsChecked(goods,oneShop.shopGoods,oneShop,allShops)"></td>
        <td>{{goods.goodsName}}</td>
        <td>{{goods.price}}元/件,共</td>
        <td><span ng-click="changeNumber(goods,oneShop.shopGoods,oneShop,allShops,'+')" style="display: inline-block;width:25px;text-align: center; border:1px solid gray;user-select: none;cursor: pointer;">+</span></td>
        <td>{{goods.number}}</td>
        <td><span ng-click="changeNumber(goods,oneShop.shopGoods,oneShop,allShops,'-')" style="display: inline-block;width:25px;text-align: center; border:1px solid gray;user-select: none;cursor: pointer;">-</span></td>
        <td>件,本商品共: {{goods.singleMoney}}元</td>
        <td ng-click="delete(innerIndex,outerIndex,oneShop,allShops)" style="user-select: none;cursor: pointer;">删除</td>
      </tr>
    </tbody>
</table>
</body>
</html>
<script>
var myApp = angular.module("myApp", []);
myApp.controller("myCtrl", function ($scope) {
  $scope.allShops = [
    {
      shopName: "专卖店一:北京鸡",
      shopGoods: [
        {
          goodsName: "北京鸡1",
          picture: "images/allShops_01.jpg",
          price: 150.0,
          singleMoney: 150.0,
          number:1
        },
        {
          goodsName: "北京鸡2",
          picture: "images/allShops_02.jpg",
          price: 119.0,
          singleMoney: 119.0,
          number:1
        },
        {
          goodsName: "北京鸡3",
          picture: "images/allShops_03.jpg",
          price: 101.0,
          singleMoney: 101.0,
          number:1
        },
      ],
    },
    {
      shopName: "专卖店二:北京鸭",
      shopGoods: [
        {
          goodsName: "北京鸭1",
          picture: "images/allShops_04.jpg",
          price: 89.0,
          singleMoney: 89.0,
          number:1
        },
        {
          goodsName: "北京鸭2",
          picture: "images/allShops_05.jpg",
          price: 99.0,
          singleMoney: 99.0,
          number:1
        },
      ],
    },
    {
      shopName: "专卖店三:北京鹅",
      shopGoods: [
        {
          goodsName: "北京鹅1",
          picture: "images/allShops_06.jpg",
          price: 289.0,
          singleMoney: 289.0,
          number:1
        },
      ],
    },
  ];
  $scope.totalValue = 0;
  //增减该件商品
  $scope.changeNumber = function (goods, shopGoods, oneShop, allShops, type) {
    if(type === '-'){
      goods.number--;
      if(goods.number <= 1) goods.number = 1;
    }else if(type === '+'){
      goods.number++;
    }
    goods.singleMoney = goods.price * goods.number;
    goods.checked = true;
    $scope.goodsChecked(goods, shopGoods, oneShop, allShops);
    $scope.getTotalMoney();
  };
  //删除该件商品
  $scope.delete = function (innerIndex, outerIndex, oneShop, allShops) {
    oneShop.shopGoods.splice(innerIndex, 1);
    if (oneShop.shopGoods.length <= 0) {
      allShops.splice(outerIndex, 1);
    }
    $scope.getTotalMoney();
  };
  /*所有商品总金额计算*/
  $scope.getTotalMoney = function () {
    var total = 0;
    angular.forEach($scope.allShops, function (outerItem) {
      angular.forEach(outerItem.shopGoods, function (innerItem) {
        if (innerItem.checked) {
          total += innerItem.price * innerItem.number;
        }
      });
    });
    $scope.totalValue = total;
  };
  /*勾选单件商品*/
  $scope.goodsChecked = function (
    goods,
    shopGoods,
    oneShop,
    allShops
  ) {
    var flag = true;
    if (goods.checked) {
      angular.forEach(shopGoods, function (innerItem) {
        if (!innerItem.checked) {
          flag = false;
        }
      });
    } else {
      $scope.allCheck = false;
      oneShop.checked = false;
      flag = false;
    }
    if (flag) {
      oneShop.checked = true;
      $scope.allCheck = true;
      angular.forEach(allShops, function (outerItem) {
        if (!outerItem.checked) {
          flag = false;
        }
      });
    }
    $scope.getTotalMoney();
  };
  /*勾选单家商铺*/
  $scope.shopChecked = function (oneShop, allShops) {
    if (oneShop.checked) {
      var flag = true;
      angular.forEach(oneShop.shopGoods, function (innerItem) {
        innerItem.checked = true;
      });
      angular.forEach(allShops, function (outerItem) {
        if (!outerItem.checked) {
          flag = false;
        }
      });
      if (flag) {
        $scope.allCheck = true;
      }
    } else {
      $scope.allCheck = false;
      angular.forEach(oneShop.shopGoods, function (innerItem) {
        innerItem.checked = false;
      });
    }
    $scope.getTotalMoney();
  };
  /*勾选全部商铺*/
  $scope.allChecked = function () {
    if ($scope.allCheck) {
      angular.forEach($scope.allShops, function (oneShop) {
        oneShop.checked = true;
        angular.forEach(oneShop.shopGoods, function (innerItem) {
          innerItem.checked = true;
        });
      });
    } else {
      angular.forEach($scope.allShops, function (oneShop) {
        oneShop.checked = false;
        angular.forEach(oneShop.shopGoods, function (innerItem) {
          innerItem.checked = false;
        });
      });
    }
    $scope.getTotalMoney();
  };
});   
</script>
  
四、angular1两种作用域绑定
angular1模块、控制器和作用域的两种绑定方式,模块不必通过ng-app关联到HTML的标签上,也不必通过angular.bootstrap()关联到HTML的标签上!
1、正常绑定
<!DOCTYPE html>
<html ng-app="app">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<body>
  <div>
    <div ng-controller="myCtrl">
      {{ hello }}
    </div>
  </div>
  <script type="text/javascript">
    var module = angular.module("app", []);
    module.controller("myCtrl", function ($scope) {
      //app模块的控制器(myCtrl)将作用域的hello 赋值为 "a Angular app"
      $scope.hello = "a Angular app";
    });
  </script>
</body>
</html>
2、异常绑定
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<body>
  <div id="app1">
    <div ng-controller="myCtrl">
      {{ hello }}
    </div>
  </div>
  <div id="app2">
    <div ng-controller="myCtrl">
      {{ hello }}
    </div>
  </div>
  <script type="text/javascript">
    var module1 = angular.module("test1", []);
    module1.controller("myCtrl", function ($scope) {
      //test1模块的控制器(myCtrl)将作用域的hello 赋值为 "a Angular app"
      $scope.hello = "a Angular app";
    });
    var module2 = angular.module("test2", []);
    module2.controller("myCtrl", function ($scope) {
      //test2模块的控制器(myCtrl)将作用域的hello 赋值为 "a Angular app"
      $scope.hello = " another Angular app";
    });
    /*此方法用于手动加载angularjs模板*/
    angular.bootstrap(document.getElementById("app1"), ['test1']);
    /*此方法用于手动加载angularjs模板*/
    angular.bootstrap(document.getElementById("app2"), ['test2']);
  </script>
</body>
</html>
 
五、两种函数传递
1、以(对象)变量传递
<!doctype html>
<html lang="en" ng-app="appModule">
<head>
  <meta charset="UTF-8">
  <title>函数当作变量传进去</title>
</head>
<body ng-controller="myCtrl">
  <p ng-click="fnClick('我是原有标签')">点击原有标签</p>
  <my-text fn="fnClick"></my-text>
  <br/>
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
  <script>
    var app = angular.module('appModule', []);
    app.controller('myCtrl', function ($scope) {
      $scope.fnClick = function (tip) {
        alert(tip)
      }
    });
    app.directive('myText', function () {
      return {
        restrict: 'E',
        template: '<h1 ng-click="thisFn()"><span>点击自定义标签</span></h1>',
        scope: {
          fn: '='
        },
        controller: function ($scope) {
          $scope.thisFn=function(){
            $scope.fn('我是自定义标签,函数当作变量传入')
          }
        }
      }
    })
  </script>
</body>
</html>
2、以函数传递
<!doctype html>
<html lang="en" ng-app="appModule">
<head>
  <meta charset="UTF-8">
  <title>函数当作函数传进去</title>
</head>
<body ng-controller="myCtrl">
  <p ng-click="fnClick('我是原有标签','AAA')">点击原有标签</p>
  <my-text fn="fnClick(tipA,tipB)"></my-text>
  <br />
  <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
  <script>
    var app = angular.module('appModule', []);
    app.controller('myCtrl', function ($scope) {
      $scope.fnClick = function (tip,pit) {
        console.log(pit)
        alert(tip)
      }
    });
    app.directive('myText', function () {
      return {
        restrict: 'E',
        template: '<h1 ng-click="thisFn()"><span>点击自定义标签</span></h1>',
        scope: {
          fn: '&'
        },
        controller: function ($scope) {
          $scope.thisFn=function(){
            $scope.fn({tipA:'我是自定义标签,函数当作函数传入',tipB:'BBB'})
          }
        }
      }
    })
  </script>
</body>
</html>
 
六、angular项目下首页文件index.html,
1、index.html注入
<!DOCTYPE html>
<html lang="en" ng-controller="mainCtrl">
<head>
</head>
<body ondragstart="return false;">
  <my-app></my-app>
</body>
<script src="/audit-html/static/common/jquery.js"></script>
/* 打包下列文件 */
<!-- build:js(src) scripts/all.min.js -->
  <!-- inject:js -->
  /* 默认js文件注入此处 */
  <!-- endinject -->
  <!-- inject:partials -->
  /* 特定js文件注入此处 */
  <!-- endinject -->
<!-- endbuild -->
</html>
2、gulp打包angular1静态文件的流程----开发环境
(1)监听到有文件变化时,向index.html文件注入css和js文件,渲染,
(2)从上到下执行css文件,
(3)从上到下渲染body,遇到组件,跳过
(4)从上到下执行js文件,遇到异步,跳过,产生依赖模块
(5)执行异步,并将根模块与html文档绑定,给根模块注入依赖,如果有依赖没定义,那么会出错,不会执行config和run
(6)解析组件,这时根组件及其内部组件所需要的html文件,按照指定路径加载,并用run函数定义全局的数据或逻辑
3、gulp打包angular1静态文件的流程----生产环境
(1)将所有的css和js文件,注入到index.html,
(2)将其它的html文件打包成1个js文件,注入到index.html,
(3)将index.html的“所有的css文件”和“所有js文件”打包,插入到另一个index.html里,渲染,
(4)从上到下执行css文件,
(5)从上到下渲染body,遇到组件,跳过
(6)从上到下执行js文件,遇到异步,跳过,产生依赖模块
(7)执行异步,并将根模块与html文档绑定,给根模块注入依赖,如果有依赖没定义,那么会出错,不会执行config和run
(8)解析组件,这时根组件及其内部组件所需要的html文件,从(2)中的js获取,并用run函数定义全局的数据或逻辑
4、执行main.js,在$stateChangeStart事件监听函数里,遇到异步跳过,直奔状态,此时状态对应的配置不存在,页面出错;正确的处理方式为,在权限异步函数的成功回调里,在前端权限列表生成后,再次执行$state.go(),填充到<ui-view>标签里;
5、根模块的依赖模块加载完毕后,根模块挂载到页面上,有如下两种情形
用法一:
<html ng-app="myApp" ng-controller="myCtrl">
  <body></body>
</html>
<script>
  //此处导入依赖['deploy1','deploy2']
  var app = angular.module('myApp', ['deploy1','deploy2']);
  app.controller('myCtrl', function ($scope) { });
</script>
用法二:
<html ng-controller="myCtrl">
  <body></body>
</html>
<script>
  var app = angular.module('myApp', ['deploy1','deploy2']);
  app.controller('myCtrl', function ($scope) { });
  //此处导入依赖['deploy1','deploy2']
  angular.bootstrap(document, ['myApp']);
</script>
6、angular版本,Google发行
(1)AngularJS,首版,2009年
(2)AngularJS,1.0版,2010年,
(3)Angular,2.0版,2016年09月份
(4)Angular,4.0版,2017年03月份
(5)Angular,5.0版,2017年11月份
(6)Angular,6.0版,2018年05月份
(7)Angular,7.0版,2018年10月份
(8)Angular,8.0版,2019年05月份
(9)Angular,9.0版,2020年02月份
(10)Angular,10.0版,2020年06月份
(11)Angular,11.0版,2020年11月份
(12)Angular,12.0版,2021年05月份
(13)Angular,13.0版,2021年12月份
(14)Angular,14.0版,2022年06月份
(15)Angular,15.0版,2022年11月份
(16)Angular,16.0版,2023年05月份
 
七、全局方法
附、原理,脏值检测,当$scope的属性值发生变化的时候,促使页面重新渲
1、config 配置模块。在提供者注册和配置阶段执行。只能注入提供者和常量配置块。在config阶段,注入 provider 的时候需要加上 provider 后缀,可以调用非 $get 方法。
2、run 运行模块。执行后创建了发射器和用于启动应用程序。只能注入运行实例和常量。返回的方法在 run 阶段注入的时候,无需加 provider 后缀,只能调用 $get 返回的方法。
3、执行的先后顺序:provider(定义默认)>config(修改默认)>run(最后执行)
(1)定义服务calc
 app.provider('calc',function () {this.currency = '&';console.log(1);});
(2)配置服务calc
 app.config(function (calcProvider) { calcProvider.currency = '钱';console.log(2);});
(3)运行服务calc
 app.run(function (calc) { console.log(3);});
另外,请求总逻辑(1)获取权限,(2)获取公共数据,(3)跳转页面。在别处获取公共数据,会出现页面已渲染、数据没到位的情况。
4、$http
$http({
  url:url,//请求的url路径
  method:method,//GET/DELETE/HEAD/JSONP/POST/PUT,DELETE会将params的配置用问号传参的方式拼接到url里,同时将data配置放在send里;
  params:params,//get请求时使用,转为?param1=xx1¶m2=xx2发送给服务器
  data:data//POST请求时使用,将被当做消息体发送给服务器
})
 
八、五种服务类型
来源:https://blog.csdn.net/qq_33587050/article/details/52138069
1、constant服务:constant不可以修改,可以注入到config里。
(1)app.constant("name",obj)
(2)name为服务的名字,obj为一个json对象.
(3)constant创建服务返回一个json对象(也就是第二个参数中传入的对象)。
2、value服务:value可以修改,不可以注入到config里。
(1)app.value("name",obj)
(2)name为服务的名字,obj为一个json对象.
(3)value创建服务返回一个json对象(也就是第二个参数中传入的对象)。
3、service服务
(1)app.service("name",constructor)
(2)name为服务的名字,第二个参数是一个构造函数,它的实例是实际被注入的服务。
4、factory服务
(1)app.factory("name",function(){return obj})
(2)name为服务的名字,第二个参数是一个普通函数,函数返回对象obj,obj是实际被注入的服务.
5、provider服务
(1)App.provider("myConfig", function () { this.$get= function () { return lastObj }});
(2)name为服务的名字,第二个参数是一个构造函数,其内要有$get方法,$get方法要返回对象lastObj,lastObj是真正被注入的服务。this.$get中的this不是myConfig,lastObj中的this才是myConfig。
6、装饰服务
(1)app.config(function($provide){ $provide.decorator("name",function($delegate){ return $delegate }) });
(2)同样是通过config,在参数函数中注入$provider服务,$provider服务有个decorator方法,它接受两个参数,第一个参数"name",是要被装饰的服务的名字,第二个参数是一个函数,函数中注入$delegate,$delegate就是被装饰的服务的实例,然后在函数中操作$delegate,就相当于操作了该服务的实例。
(3)示例:
app.config(function ($provide) {//通过config,在参数函数中注入$provider服务
    $provide.decorator('name',function ($delegate) {//$provider服务有个decorator方法,它接受两个参数,
        var fn = $delegate; //先保存以前的$delegate
        $delegate = function () {//在外面套一层函数
            var list = Array.from(arguments);
            list[1] = list[1]+2000;
            fn.apply(null,list);
        };
        return $delegate;//在函数中返回$delegate;
    })
});
 
九、过滤
1、表达式中添加过滤器
  <p>姓名为 {{ lastName | uppercase }}</p>
  <p>姓名为 {{ lastName | lowercase }}</p>
  <p>总价 = {{ (quantity * price) | currency }}</p>
2、向指令添加过滤器
  <li ng-repeat="x in names | orderBy:'country'">
    {{ x.name + ', ' + x.country }}
  </li>
  <input type="text" ng-model="test">
  <li ng-repeat="x in names | filter:test | orderBy:'country'">
    {{ (x.name | uppercase) + ', ' + x.country }}
  </li>
3、自定义过滤器
  app.filter('reverse', function() { //可以注入依赖
      return function(text) {
          return text.split("").reverse().join("");
      }
  });
4、filter使用规则:
(1)用来处理一个数组,然后可以过滤出含有某个子串的元素,作为一个子数组来返回。
(2)可以是字符串数组,也可以是对象数组。
(3)如果是对象数组,可以匹配属性的值。
(4)如果是字符串数组,可以匹配字符串的组成部分。
 
十、重要指令(ng-) 
1、ng-if、ng-hide、ng-show的用法
  (1)ng-if 如果条件为 false时; “移除” HTML 元素。
  (2)ng-show 如果条件为 false时; “隐藏” HTML 元素。
  (3)ng-hide 如果条件为 true时; “隐藏” HTML 元素。
  (4)ng-trim="false",自动去掉(input)前后空格。
  (5)ng-bind与{{}}的区别,ng-bind可以解决后者闪烁加载的问题
  另外:<span> {{protoNum}} </span>
    <img src="" ng-hide="protoNum==undefined? false:protoNum+1"/>
    (1)在HTML里,undefined+1的运行结果是字符串“undefined1”,
    (2)在js里,undefined+1的运行结果是数字NaN。
2、ng-repeat:用于遍历数组或对象,
(1)<tr ng-repeat="(key,value) in arrayOrObject"><td>{{key}}{{value}}</td></tr>,
  用这种格式遍历数组,key是每一项的索引,value是每一项的值。
  用这种格式遍历对象,key是每一项的属性名,value是每一项的属性值。
(2)<tr ng-repeat="item in arrayOrObject"><td>{{item}}</td></tr>,
  用这种格式遍历数组,item是数组中的每一项;
  用这种格式遍历对象,item是对象中的每一项的属性值。
3、ng-model
  以<input type="text" ng-model="name">{{name}}为例:
(1)如果input所在的作用域内已经声明name并给name赋值了,那么ng-model会把该值获取到,并在input里输出。同时{{name}}也会把该值取到页面上。
  当input里面的值改变时,ng-model把作用域内的name值进行修改,同时{{name}}也会用修改后的name值覆盖原来页面上的name值。
(2)如果input所在的作用域内没有声明name,那么ng-model会在作用域内声明一个name。
  当input里面输入值后,ng-model会对作用域内的name进行赋值,同时{{name}}也会在页面上输出。
(3)原理:ng-model根据input标签的type属性值的不同,监听用户的输入事件如onchange,onkeyup,onkeydown。
(4)type="radio"
  ng-model的值就是选中的那个radio所对应的ng-value的值;初始化单选框,yesOrNo=1,则前者选中,yesOrNo=2,则后者选中,此单选框被选中;点击1单选框,则1单选框被选中,赋值yesOrNo=1
  <input type="radio" name="inlineRadioOptions" ng-model="yesOrNo" ng-value="1">。//ng-value:设置输入框的值。
  <input type="radio" name="inlineRadioOptions" ng-model="yesOrNo" ng-value="2">。//ng-value:设置输入框的值。
(5)type="checkbox"
  <input type="checkbox" ng-model="all"> Check all<br><br>
  <input type="checkbox" ng-checked="all">Volvo<br>
  <input type="checkbox" ng-checked="all">Ford<br>
  <input type="checkbox" ng-checked="all">Mercedes
(6)<select ng-model="myLog.resultDo" ng-options="item.value as item.key for item in resultDo"></select>
  $scope.resultDo = [
    { value: '', key: '全部' },
    { value: '已读', key: '已读' },
    { value: '未读', key: '未读' }
  ]
  https://blog.csdn.net/mydtudysy/article/details/78040969
4、ng-bind-html,如果没有$sce或$sanitize的辅助,它是不会生效的。
  (1)内置的$sce.trustAsHtml(),它不经过净化,直接将html绑定给元素,保留所有的属性和事件。
  (2)注入第三方模块ngSanitize就行了,不用注入$sanitize服务,$sanitize会自动对html标签进行净化,并会把标签的属性以及绑定在元素上的事件都移除,仅保留了标签和内容。
  (3)$sce用法示例
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
    </head>
    <body ng-app="myApp" ng-controller="myCtl">
    <div ng-bind-html="content">
    </div>
    </body>
    </html>
    <script>
        var app = angular.module('myApp', []);
        app.controller('myCtl',function($scope,$sce){
            $scope.temporaryContent="My name is: <h1 style='color:red'>John Doe</h1>";
            $scope.content = $sce.trustAsHtml($scope.temporaryContent);
        });
    </script>
(4)ngSanitize用法示例
  <!DOCTYPE html>
  <html>
  <head>
      <meta charset="UTF-8">
      <title></title>
      <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
      <script src="https://cdn.bootcss.com/angular-sanitize/1.5.9/angular-sanitize.js"></script>
  </head>
  <body >
  <div ng-app="myApp" ng-controller="myCtrl">
      <p ng-bind-html="myText"></p>
  </div>
  </body>
  </html>
  <script>
    var app = angular.module("myApp", ['ngSanitize']);
    app.controller("myCtrl", function($scope) {
        $scope.myText = "My name is: <h1 style='color:red'>John Doe</h1>";
    });
  </script>
5、ng-class(三元、数组、对象)、ng-bind(三元、数组)、ng-style(三元)与ng-src(三元双括号)用法示例
  <!DOCTYPE html>
  <html lang="en" ng-app="myModel">
  <head>
    <meta charset="UTF-8">
    <title>样式</title>
    <style>
      .red{color:red}
      .green{color:green}
    </style>
    <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  </head>
  <body>
    <div ng-controller="firstCtrl">
      <div ng-class="isTrue?'red':'green'">1、class三元</div>
      <div ng-class="['red','green'][num1]">2、class数组</div>
      <div ng-class="{'red':isTrue,'green':!isTrue}">3、class对象</div>
      <div ng-style="isTrue?{'color':'green','width':'200px'}:{'color':'red','width':'300px'}">4、style三元</div>
      <div ng-style="{'color': isTrue? 'red':'green','width': isTrue? '200px':'300px', }">5、style对象(三元)</div>
      <div ng-style="{'color': ['red','green'][num1], }">6、style对象(数组)</div>
      <div><span ng-bind="isTrue?'7、':'8、'"></span><span>bind三元</span></div>
      <div><span ng-bind="['7、','8、'][num1]"></span><span>bind数组</span></div>
      <div><span>{{isTrue?'9、':'0、'}}</span><span>三元取值</span></div>
      <div><span>{{['9、','0、'][num1]}}</span><span>数组取值</span></div>
    </div>
  </body>
  </html>
  <script>
    var app = angular.module('myModel', []);
    app.controller('firstCtrl', function ($scope) {
      $scope.isTrue=true;
      $scope.num1=1;
      $scope.width='200px';
      $scope.height='20px';
    });
  </script>
  <img ng-src="{{isTrue?path1:path2}}" alt=""/>
6、ng-transclude
  <!DOCTYPE html>
  <html lang="en" ng-app="myModel">
  <head>
    <meta charset="UTF-8">
    <title>多个插槽之angular1.6.2版</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  </head>
  <body>
    <div ng-controller="thisCtrl">
      <panel color="blue">
        <panel-header><h1>{{title}}</h1></panel-header>
        <panel-body><h1>{{content}}</h1></panel-body>
        <panel-footer><h1>{{footer}}</h1></panel-footer>
      </panel>
    </div>
  </body>
  <script>
    var app = angular.module('myModel', []);
    app.controller('thisCtrl',function($scope){
      $scope.title = "头";
      $scope.content = "体";
      $scope.footer = "脚";
    });
    app.directive('panel', function(){
      return {
        template: `
          <div style="color:{{aaa}}">
            <div>下面放置插槽header:</div>
            <div ng-transclude="header"></div>
            <div>下面放置插槽body:</div>
            <div ng-transclude="body"></div>
            <div>下面放置插槽footer:</div>
            <div ng-transclude="footer"></div>
          </div>
        `,
        restrict: 'E',
        replace: true,
        transclude: {
          'header': 'panelHeader',
          'body': 'panelBody',
          'footer': 'panelFooter'
        },
        controller: function ($scope) {
             
        },
        link: function (scope, element, attr,) {
          scope.aaa = attr.color
        
      }
    });
  </script>
  </html>
7、ng-app
  根模块的依赖模块加载完毕后,根模块才可以挂载到页面上
  (1)用法一
    <html ng-app="myApp" ng-controller="myCtrl">
      <body></body>
    </html>
    <script>
      //此处导入依赖['deploy1','deploy2']
      var app = angular.module('myApp', ['deploy1','deploy2']);
      app.controller('myCtrl', function ($scope) { });
    </script>
  (2)用法二
    <html ng-controller="myCtrl">
      <body></body>
    </html>
    <script>
      var app = angular.module('myApp', ['deploy1','deploy2']);
      app.controller('myCtrl', function ($scope) { });
      //此处导入依赖['deploy1','deploy2']
      angular.bootstrap(document, ['myApp']);
    </script>
 
十一、单选框|复选框|下拉框三者联合案例展示
说明:单选框与复选框在点击事件发生时的区别
1、单选框在点击后:呈现选中状态,ng-model取值ng-value(初始化时,两者相等则选中);
2、复选框在点击后:呈现相反状态,ng-model取反ng-model(初始化时,布尔转换ng-checked的结果赋值给ng-model,决定是否选中),ng-checked永远保持原始值;
  <!DOCTYPE html>
  <html lang="en" ng-app="myModel">
  <head>
    <meta charset="UTF-8">
    <title>联合案例展示</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  </head>
  <body>
  <div ng-controller="firstCtrl">
    <div style="margin-bottom:30px;">
      <span>右边是type="checkbox"</span>
      <input type="checkbox" style="width:20px;transform:scale(2)" ng-checked="checkboxCheck" ng-model="checkboxModel" ng-click="checkbox()">
    </div>
    <div style="margin-bottom:30px;">
      <span>右边是select</span>
      <select ng-model="myLog.resultDo" ng-options="item.back as item.front for item in resultDo" style="width:120px;height:30px" ng-change="selectOption()"></select>
    </div>
    <div style="margin-bottom:30px;">
      <span>右边是type="radio"</span>
      <input id="terminal" type="radio" name="options" ng-model="deviceMode.mode" ng-value="0" style="width:20px;transform:scale(2)" ng-click="selectRadio()"/>
      <label for="terminal" style="margin-right:40px;" ng-click="selectRadio()">终端</label>
      <input id="platform" type="radio" name="options" ng-model="deviceMode.mode" ng-value="1" style="width:20px;transform:scale(2)" ng-click="selectRadio()"/>
      <label for="platform" ng-click="selectRadio()">平台</label>
    </div>
    </div>
  </body>
  </html>
  <script>
    var app = angular.module('myModel', []);
    app.controller('firstCtrl', function ($scope) {
      $scope.myLog={resultDo:"全部后台"};
      $scope.resultDo = [{ back: '全部后台', front: '全部前端' },{ back: '已读后台', front: '已读前端' },{ back: '未读后台', front: '未读前端' }];
      $scope.deviceMode = {mode: 0};
      $scope.checkboxCheck = false;/*永远不变*/
      $scope.checkboxModel = true;/*交替改变*/
      $scope.checkbox = function () {
        console.log($scope.checkboxCheck);
        console.log($scope.checkboxModel)
      };
      $scope.selectRadio = function () {
        console.log($scope.deviceMode)
      };
      $scope.selectOption = function () {
        console.log($scope.myLog.resultDo)
      };
    });
  </script>
3、下拉框分组
  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title></title>
    <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.2/angular.js"></script>
  </head>
  <body ng-app="myapp">
    <div ng-controller="mainCtrl">
      <div>
        <p>你的选择是:{{selectedOption}}</p>
        <select ng-options="item.id as item.name group by item.sex for item in resultDo"
          ng-model="selectedOption"></select>
      </div>
    </div>
    <script type="text/javascript">
      var myapp = angular.module('myapp', []);
      myapp.controller('mainCtrl', ['$scope', function ($scope) {
        $scope.selectedOption ="hanmeimei";
        //定义包含对象的数组 resultDo
        $scope.resultDo = [
          { "id": "lilei", "name": "李雷", "sex": "man" },
          { "id": "hanmeimei", "name": "韩梅梅", "sex": "woman" },
          { "id": "jack", "name": "杰克", "sex": "man" }
        ];
      }])
    </script>
  </body>
  </html>
4、下拉框可输入
  <div class="form-group">
    <label>资产名称</label>
    <div class="form-group">
      <input
        list="device_name"
        type="text"
        class="form-control"
        style="width: 300px" ng-model="addDialogItem.device_name"/>
      <datalist id="device_name">
        <option
          ng-repeat="option in assetName track by $index"
          value="{{option.device_name}}">{{option.device_name}}</option>
      </datalist>
    </div>
  </div>
 
十二、子组件向父组件传值
附:兄弟组件传值,在父组件的作用域里定义一个对象,分别传给两个子组件,在子组件里,给该对象的一个属性赋值
1、属性传值
  思路:在父组件定义一个函数,在函数体里,将函数的参数赋值给父组件$scope的一个属性;通过属性传参的方式把这个函数传给子组件。在子组件里,给这个函数传参并执行,实现子组件向父组件传值!
  另外,页面改变组件的值,在页面刚渲染时,就向后台发送请求,获取数据,把数据对象与组件的ng-if绑定,同时作为参数传给组件,在子组件里给参数添加一个函数属性,通过页面的数据对象调用该函数!如果数据对象不与组件的ng-if绑定,那么组件在渲染时,会因没有数据而出现页面错误!
  也可以将ng-iffalse绑定,等到数据对象生成后,再与true绑定!
  <!DOCTYPE html>
  <html lang="en" ng-app="appModule" ng-controller="ancestorCtrl">
    <head>
        <meta charset="UTF-8">
        <title>子组件向父组件传值</title>
        <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
    </head>
    <body>
      <my-parent></my-parent>
    </body>
  </html>
  <script>
    var app = angular.module('appModule', []);
    app.controller("ancestorCtrl", function ($scope) {});
    app.directive('myParent', function () {
      return {
        template: "<div><my-child son-method='parentMethod'></my-child>" + "<div>{{sonData}}</div></div>",
        restrict: 'E',//指令类型  E:element A:attribute M:comment C: class
        replace: true,//模板放在<my-parent>内部还是取代它,默认是false,放在其内部
        controller: function ($scope) {
          $scope.parentMethod = function (key) {
            $scope.sonData = key;
          };
        },
      }
    });
    app.directive('myChild', function () {
      return {
        template: "<div><button ng-click='thisMethod(\"222\")'>点击获取来自子组件的数据</button></div>",
        restrict: 'E',
        replace: true,
        scope: {
          sonMethod:'=sonMethod'
        },
        controller: function ($scope) {
          $scope.index = 1;
          $scope.thisMethod = function (key) {
            $scope.index += 1;
            $scope.sonData = key + $scope.index;
            $scope.sonMethod($scope.sonData)
          };
        },
      }
    })
  </script>
2、监听传值
  <body>
    <div ng-controller="parent">
      Parent: {{parent}}
      <input type="text" ng-model="parent"/>
      <div ng-controller="child">
        {{change}} Child: {{child}}
      </div>
    </div>
  </body>
  (1)父广播、子监听
    angular.module("app", [])
      .controller("parent", function($scope) {
        $scope.$watch("parent", function(n, o) {
          if (n == o) {
            return;
          }
          $scope.$broadcast("parentChange", n)
        })
      })
      .controller("child", function($scope) {
        $scope.$on("parentChange", function(e, m) {
          $scope.change = "changed";
          $scope.child = m;
        })
      })
    </script>
  (2)父监听、子发射
    angular.module("app", [])
      .controller("parent", function($scope) {
        $scope.$on("childChange", function(e, m) {
          $scope.change = "changed";
          $scope.parent = m
        })
      })
      .controller("child", function($scope) {
        $scope.$watch("child", function(n, o) {
          if (n == o) {
            return;
          }
          $scope.$emit("childChange", n)
        })
      })
    </script>
  另有,孙:发射、祖:先监听后广播
 
十三、directive自定义标签
1、基本案例
  <!DOCTYPE html>
  <html lang="en" ng-app="appModule" ng-controller="thisCtrl">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
  </head>
  <body>
    <this-div outer-function='outerFunction'>
      <button ng-click="slotFunction()">这是插槽-可以读取当前页的内容</button>
    </this-div>
  </body>
  </html>
  <script>
    var app = angular.module('appModule', []);
    app.controller("thisCtrl", function ($scope) {
      $scope.slotContent = "这是组件的插槽内容!";
      $scope.slotFunction = function () {
        console.log($scope.slotContent)
      };
      $scope.outerFunction= function () {
        console.log($scope.slotContent)
      };
    });
    app.directive('thisDiv', function () {
      var str = '';
      str += "<div>";
      str += "<div ng-transclude></div>";
      str += "<button ng-click='innerFunction()'>这是组件-可以读取当前页的内容</button>";
      str += "</div>";
      return {
        template: str,
        restrict: 'E',
        replace: true,
        transclude: true,
        scope: {
          outerFunction: '='
        },
        controller: function ($scope) {
          $scope.innerFunction = function () {
            $scope.outerFunction()
          }
        }
      }
    });
  </script>
2、嵌套
  <!DOCTYPE html>
  <html lang="en" ng-app="appModule" ng-controller="ancestorCtrl">
  <head>
      <meta charset="UTF-8">
      <title></title>
      <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
  </head>
  <body>
  <my-parent>
      {{ancestorName}}
      <my-child selfAttr="myAttr">{{childName}}</my-child>
  </my-parent>
  </body>
  </html>
  <script>
      var app = angular.module('appModule', []);
      app.controller("ancestorCtrl", function ($scope) {
          $scope.ancestorName = "我所处的位置,表明我只能在ng-transclude里出现。";
          $scope.childName = "变量必须定义在作用域里,myParent和myChild的作用域我进不去。";
      });
      app.directive('myParent', function () {
          return {
              template: "<div><p>第一段</p>" + "<div ng-transclude></div>" + "<p>第二段</p>" + "<div>{{parentName}}</div></div>",
              //template: '<div>我是指令生<div ng-transclude></div>成的内容</div>',//templateUrl导入自定义元素的模板
              restrict: 'E',//指令类型  E:element A:attribute M:comment C: class
              replace: true,//模板放在<my-parent>内部还是取代它,默认是false,放在其内部
              transclude: true,//是否保留自定义指令开闭标签之间的内容,该内容插入模板中使用ng-transclude属性的地方,默认为false,如上。<div ng-view></div>通过路由放入数据
              scope: {
                //获取自定义标签的属性值//false:继承父作用域;true:继承父作用域且创建独立作用域;{}:不继承父作用域且创建独立作用域。
                //scope:{name:'@name',绑定字符串  name:'=name',绑定变量  name:'&name',绑定函数}。传进来的变量,在值改变后,父作用域的该变量的值也随之改变。
              },
              controller: function ($scope) {
                //指令的controller和link可以进行互换。controller的主要作用(1)导入自定义或ng内置的服务;(2)提供可在子指令里复用的行为。
                $scope.focusAAA = function () {};
                this.parentMethod = function (son) {
                  console.log('son:',son);
                }
              },
              compile: function(element, attributes) {
                //compile和link是相斥的。如果同时设置了两项,compile返回的函数会被当作链接函数把后面定义的link函数所取代,也就是说,后面的link函数将起不到作用。controller先运行,compile后运行,link不运行
              },
              link: function (scope, element, attr, ctrl, linker) {}
          }
      });
      app.directive('myChild', function () {
          return {
              template: "<div><span ng-click='toParent()'>这里是span1;</span><span>这里是span2。</span><div ng-transclude></div></div>",
              restrict: 'E',
              replace: true,
              transclude: true,
              scope: {},
              require: '?^myParent',//?不要抛出异常;^允许查找父元素的controller
              controller: function ($scope) {
                console.log( $scope.parentMethod  )
              },
              /*compile: function(element, attributes) {},*/
              //'myParent':在当前指令中查找控制器;'^myParent'在上游指令中查找控制器;'?^myParent':当前指令若没有,就向上游查找
              link: function (scope, element, attr, ctrl, linker) {
                  ctrl.parentMethod();
                  linker(scope, function (clone) {
                      console.log(clone.text())
                  })
              }
          }
      })
  </script>
 
十四、获取不到新value
  症状:angular对象数据的value被更改后,获取的仍然是旧value
  原因:在第三方插件或原生JS里进行的变化,没法触发脏值检测。
    angular.module('myApp', []).controller('MessageController', function ($scope) {
      $scope.getMessage = function () {
        setTimeout(function () {
          $scope.$apply(function () {
            $scope.message = 'Fetched after 3 seconds';
            console.log('message:' + $scope.message);
          });
        }, 2000);
      }
      $scope.getMessage();
    });
    $scope.getMessage = function () {
      setTimeout(function () {
        $scope.message = 'Fetched after two seconds';
        console.log('message:' + $scope.message);
        $scope.$apply(); //this triggers a $digest
      }, 2000);
    }
    angular.element(document).ready(function () {
      var config = {
        elem: '#' + $scope.dateInputId,
        theme: '#007bff',
        trigger: 'click',
        done: function (value) {
          $scope.dateModel = value;
          $scope.$apply();//在此处执行
          angular.isFunction($scope.updata) ? $scope.updata() : '';
          //在此处执行无效
        }
      };
      laydate.render(config);
    });
 
十五、[].forEach|$.each|angular.forEach用法示例
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title></title>
    </head>
    <body>
      本代码不能运行
    </body>
  </html>
  <script>
    //[].forEach
    [3, 3, 3].forEach(function (a, b, c, d) {
      //3 0 [ 3, 3, 3, 3, 3 ] undefined
      console.log(a, b, c, d)
    })
    //$.each
    $.each([3, 3, 3, 3], function (a, b, c) {
      console.log(a, b, c)
      //0 3 undefined
 
    })
    $.each({ a: 'b' }, function (a, b) {
      console.log(a, b)
      //a,b
    });
    //angular.forEach
    angular.forEach([3, 3, 3], function (a, b, c, d) {
      console.log(a, b, c, d)
      //3 0 Array(6) undefined
    });
    angular.forEach({ a: 'b' }, function (a, b) {
      console.log(a, b)
      //b,a
    });
  </script>
 
十六、ui.router路由模块
1、提供$stateProvider对象,
  (1)用$stateProvider.state(stateNameString, stateConfigObject)配置路由。
  (2)用template去替换<ui-view></ui-view>或<div ui-view></div>。
  (3)stateConfigObject包含以下内容:
  (3-1)template: string/function,html模板字符串,或者一个返回html模板字符串的函数。
  (3-2)templateUrl:string/function,模板路径的字符串,或者返回模板路径字符串的函数。
  (3-3)templateProvider:function,返回html模板字符串或模板路径的服务。
  (3-4)controller:string/function,新注册一个控制器函数或者一个已注册的控制器的名称字符串。
  (3-5)controllerProvider:function,返回控制器或者控制器名称的服务
  (3-6)controllerAs:string,控制器别名。
  (3-7)parent:string/object,手动指定该状态的父级。
  (3-8)resolve:object,将会被注入controller去执行的函数,<string,function>形式。
  (3-9)url:string,当前状态的对应url。
  (3-10)views:object,视图展示的配置。<string,object>形式。
  (3-11)abstract:boolean,一个永远不会被激活的抽象的状态,但可以给其子级提供特性的继承。默认是true
  (3-12)onEnter:function,当进入一个状态后的回调函数。
  (3-13)onExit:function,当退出一个状态后的回调函数。
  (3-14)reloadOnSearch:boolean,如果为false,那么当一个search/query参数改变时不会触发相同的状态,用于当你修改$location.search()的时候不想重新加载页面。默认为true
  (3-15)data:object,任意对象数据,用于自定义配置。继承父级状态的data属性。换句话说,通过原型继承可以达到添加一个data数据从而整个树结构都能获取到。
  (3-16)params:url里的参数值,通过它可以实现页面间的参数传递。params:{params1:null,params2:null...}
2、提供$urlRouterProvider对象,
  (1)用$urlRouterProvider.when(url,otherUrl/handler)配置匹配的前端路由,
  (2)用$urlRouterProvider.otherwise('/login')配置不匹配的前端路由。
3、ui.router实际执行步骤
  附1、ngRoute模块提供$routeProvider服务
    1、$routeProvider.when('/bookDetail/:bookId',{}).when()
    2、<a class="btn btn-default" href="#/bookDetail/{{book.id}}">//实参
    3、var bookId = $routeParams.bookId;//获取实参
  附2、ui.router和ngRoute的区别
    1、ui.router模块提供$urlRouterProvider、$stateProvider、$stateParams服务
    2、ngRoute模块提供$routeProvider、$routeParams服务
(1)定义路由状态;
  $stateProvider
  .state('page2', {
    url: '/event-safe/:thisParams',
    params: {
      thisParams: null//前端可以根据thisParams的取值不同,进行不同的处理,与上面的:thisParams二选一使用
    },
    templateUrl: 'event/event-safe.html',
    controller: 'eventSafeCtrl',
  })
(2)激活路由的方式
  (2-1)$state.go():优先级最高的激活方式,$state.go('page',{ thisParams: '123'}),获取路由参数$stateParams.params;
  (2-2)ui-sref:点击包含此指令跳转,例如<a ui-sref="page2({type:1})"></a>
  (2-3)ng-href:<a ng-href="#/page2/1"></a>
(3)ui.router路由嵌套:通过 .语法进行路由层级配置
  代码示例一:
  /* 以下是index.html */
  <div>
    <span>其他内容</span>
    <a ui-sref="about">About</a>
    <a ui-sref="home">Home</a>
    <span>其他内容</span>
    <div ui-view></div>
  </div>
  /* 以下是home.html */
  <div>
    <span>其他内容</span>
    <a ui-sref=".list">List</a>
    <a ui-sref=".graph">Paragraph</a>
    <span>其他内容</span>
    <div ui-view></div>
  </div>
  $stateProvider
    .state("about", {
      url: "/about",
      templateUrl: "about.html",
    })
    .state("home", {
      url: "/home",
      templateUrl: "home.html",
    })
    .state("home.list", {
      url: "/list",
      templateUrl: "home-list.html",
      controller: function ($scope) {
        $scope.dogs = ["Bernese", "Husky", "Goldendoodle"];
      },
    })
    .state("home.graph", {
      url: "/graph",
      template: "I could sure use a drink right now.",
    });
  代码示例二:
  <div>
    <div ui-view="filters"></div>
    <div ui-view="mailbox"></div>
    <div ui-view="priority"></div>
  </div>
  $stateProvider
    .state('inbox', {
      views: {
        'filters': {
          template: '<h4>Filter inbox</h4>',
          controller: function($scope) {}
        },
        'mailbox': {
          templateUrl: 'partials/mailbox.html'
        },
        'priority': {
          template: '<h4>Priority inbox</h4>',
          resolve: {
            facebook: function() {
              return FB.messages();
            }
          }
        }
      }
    });
  
十七、jqLite的API参考
1、在jQuery中,$()里面是通过各种选择器获得元素;
2、在jqLite中,通过angular.element(param)获得元素;param只有两种:一种是类似html元素的字符串,一种是Dom元素。如:
  var email=angular.element('<input name="email" id="myId"></input>');
  var email=angular.element(document.getElementById(‘myId’));
3、jqLite API参考:https://blog.csdn.net/chi1130/article/details/78556097
  01、addClass()  //为每个匹配的元素添加指定的样式类名
  02、after() 在匹配元素集合中的每个元素后面插入参数所指定的内容,作为其兄弟节点
  03、append()    //在每个匹配元素里面的末尾处插入参数内容
  04、attr()  //获取匹配的元素集合中的第一个元素的属性的值
  05、bind()  //为一个元素绑定一个事件处理程序
  06、children()  //获得匹配元素集合中每个元素的子元素,选择器选择性筛选
  07、clone() //创建一个匹配的元素集合的深度拷贝副本
  08、contents()  //获得匹配元素集合中每个元素的子元素,包括文字和注释节点
  09、css()   //获取匹配元素集合中的第一个元素的样式属性的值
  10、data()  //在匹配元素上存储任意相关数据
  11、detach()    //从DOM中去掉所有匹配的元素
  12、empty() //从DOM中移除集合中匹配元素的所有子节点
  13、eq()    //减少匹配元素的集合为指定的索引的哪一个元素
  14、find()  //通过一个选择器,jQuery对象,或元素过滤,得到当前匹配的元素集合中每个元素的后代
  15、hasClass()  //确定任何一个匹配元素是否有被分配给定的(样式)类
  16、html()  //获取集合中第一个匹配元素的HTML内容
  17、next()  //取得匹配的元素集合中每一个元素紧邻的后面同辈元素的元素集合。如果提供一个选择器,那么只有紧跟着的兄弟元素满足选择器时,才会返回此元素
  18、on()    //在选定的元素上绑定一个或多个事件处理函数
  19、off()   //移除一个事件处理函数
  20、one()   //为元素的事件添加处理函数。处理函数在每个元素上每种事件类型最多执行一次
  21、parent()    //取得匹配元素集合中,每个元素的父元素,可以提供一个可选的选择器
  22、prepend()   //将参数内容插入到每个匹配元素的前面(元素内部)
  23、prop()  //获取匹配的元素集中第一个元素的属性(property)值
  24、ready() //当DOM准备就绪时,指定一个函数来执行
  25、remove()    //将匹配元素集合从DOM中删除。(同时移除元素上的事件及 jQuery 数据。)
  26、removeAttr()    //为匹配的元素集合中的每个元素中移除一个属性(attribute)
  27、removeClass()   //移除集合中每个匹配元素上一个,多个或全部样式
  28、removeData()    //在元素上移除绑定的数据
  29、replaceWith()   //用提供的内容替换集合中所有匹配的元素并且返回被删除元素的集合
  30、text()  //得到匹配元素集合中每个元素的合并文本,包括他们的后代
  31、toggleClass()   //在匹配的元素集合中的每个元素上添加或删除一个或多个样式类,取决于这个样式类是否存在或值切换属性。即:如果存在(不存在)就删除(添加)一个类
  32、triggerHandler()    //为一个事件执行附加到元素的所有处理程序
  33、unbind()    //从元素上删除一个以前附加事件处理程序
  34、val()   //获取匹配的元素集合中第一个元素的当前值
  35、wrap()  //在每个匹配的元素外层包上一个html元素

  

posted @   WEB前端工程师_钱成  阅读(8522)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示