AngularJs 如何实现多级联动且最后一级下拉可以选择多个选项。请附上正确例子
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AngularJs 如何实现多级联动且最后一级下拉可以选择多个选项。请附上正确例子相关的知识,希望对你有一定的参考价值。
参考技术A <select ng-model="selectedDistrict" ng-change="selectedUnit=''" ng-options="district.name for district in districts" class="ng-valid ng-dirty"></select><select ng-model="selectedUnit" ng-change="selectedPosition=''" ng-options="unit.name for unit in selectedDistrict.units" class="ng-valid ng-dirty"></select>
这个是两级联动。如果要多选,建议你用插件isteven-multi-select。 参考技术B AngularJs好像没有这么强大 没法实现
WebForm使用AngularJS实现下拉框多级联动
- 数据准备1 using System.Collections.Generic;
2 using System.Linq;
3
4 namespace FourLevelDemo.Services
5 {
6 public class CategoryService
7 {
8 private static List<Category> GetCategories()
9 {
10 return new List<Category>(new[]
11 {
12 new Category
13 {
14 CateId = 1,
15 CateName = "A1",
16 Depth = 1,
17 ParentId = 0,
18 SubCategories = new List<Category>(new[]
19 {
20 new Category
21 {
22 CateId = 101,
23 CateName = "A101",
24 Depth = 2,
25 ParentId = 1,
26 SubCategories = new List<Category>(new[]
27 {
28 new Category
29 {
30 CateId = 10101,
31 Depth = 3,
32 CateName = "A10101",
33 ParentId = 101,
34 SubCategories = new List<Category>(new[]
35 {
36 new Category
37 {
38 CateId = 1010101,
39 CateName = "A1010101",
40 Depth = 4,
41 ParentId = 10101,
42 },
43 new Category
44 {
45 CateId = 1010102,
46 CateName = "A1010102",
47 Depth = 4,
48 ParentId = 10101,
49 },
50 new Category
51 {
52 CateId = 1010103,
53 CateName = "A1010103",
54 Depth = 4,
55 ParentId = 10101,
56 }
57 })
58 },
59 new Category
60 {
61 CateId = 10102,
62 CateName = "A10102",
63 Depth = 3,
64 ParentId = 101,
65 SubCategories = new List<Category>(new[]
66 {
67 new Category
68 {
69 CateId = 1010201,
70 CateName = "A1010201",
71 Depth = 4,
72 ParentId = 10102,
73 },
74 new Category
75 {
76 CateId = 1010202,
77 CateName = "A1010202",
78 Depth = 4,
79 ParentId = 10102,
80 },
81 new Category
82 {
83 CateId = 1010203,
84 CateName = "A1010203",
85 Depth = 4,
86 ParentId = 10102,
87 }
88 })
89 },
90 new Category
91 {
92 CateId = 10103,
93 CateName = "A10103",
94 Depth = 3,
95 ParentId = 101,
96 SubCategories = new List<Category>(new[]
97 {
98 new Category
99 {
100 CateId = 1010301,
101 CateName = "A1010301",
102 Depth = 4,
103 ParentId = 10103,
104 },
105 new Category
106 {
107 CateId = 1010302,
108 CateName = "A1010302",
109 Depth = 4,
110 ParentId = 10103,
111 },
112 new Category
113 {
114 CateId = 1010303,
115 CateName = "A1010303",
116 Depth = 4,
117 ParentId = 10103,
118 }
119 })
120 }
121 })
122 },
123 new Category
124 {
125 CateId = 102,
126 CateName = "A102",
127 Depth = 2,
128 ParentId = 1,
129 SubCategories = new List<Category>(new[]
130 {
131 new Category
132 {
133 CateId = 10201,
134 CateName = "A10201",
135 Depth = 3,
136 ParentId = 102,
137 SubCategories = new List<Category>(new[]
138 {
139 new Category
140 {
141 CateId = 1020101,
142 CateName = "A1020101",
143 Depth = 4,
144 ParentId = 10201,
145 },
146 new Category
147 {
148 CateId = 1020102,
149 CateName = "A1020102",
150 Depth = 4,
151 ParentId = 10201,
152 },
153 new Category
154 {
155 CateId = 1020103,
156 CateName = "A1020103",
157 Depth = 4,
158 ParentId = 10201,
159 }
160 })
161 },
162 new Category
163 {
164 CateId = 10202,
165 CateName = "A10202",
166 Depth = 3,
167 ParentId = 102,
168 SubCategories = new List<Category>(new[]
169 {
170 new Category
171 {
172 CateId = 1020201,
173 CateName = "A1020201",
174 Depth = 4,
175 ParentId = 10202,
176 },
177 new Category
178 {
179 CateId = 1020202,
180 CateName = "A1020202",
181 Depth = 4,
182 ParentId = 10202,
183 },
184 new Category
185 {
186 CateId = 1020203,
187 CateName = "A1020203",
188 Depth = 4,
189 &nbs以上是关于AngularJs 如何实现多级联动且最后一级下拉可以选择多个选项。请附上正确例子的主要内容,如果未能解决你的问题,请参考以下文章