我正在尝试制作一个多选列表,上面有一个下拉列表作为过滤器。上面的下拉列表的值包含部门名称,然后根据上面选择的部门在下面的列表中显示其员工。
这是我的范围:
var self = this;
self.users = [{ department: "A", name: "santos" }, { department: "B", name: "suarez" }, { department: "C", name: "domingo" }, { department: "A", name: "james" }, { department: "B", name: "black" }, { department: "C", name: "de leon" }, { department: "A", name: "dela cruz" }, { department: "B", name: "robertson" }, { department: "C", name: "williams" }, { department: "A", name: "crawford" },
{ department: "B", name: "garcia" }, { department: "C", name: "navarro" }, { department: "A", name: "lim" }, { department: "B", name: "lee" }, { department: "C", name: "vasquez" }, { department: "A", name: "montano" }, { department: "B", name: "trump" }, { department: "C", name: "arroyo" }, { department: "A", name: "aquino" }, { department: "B", name: "duterte" }];
这是我的HTML:
<select class="form-control" ng-options="item as item.department for item in formsDcfCtrl.users" ng-model="departmentsList">
<option value="" selected>Departments</option>
</select>
<select multiple class="form-control" ng-options="x as x.name for x in formsDcfCtrl.users | filter:departmentsList" ng-model="usersList"></select>
但我得到了不同的结果:
下面列表的值很好,但下拉列表的值基于数组中各部门的值:
当我从下拉列表中选择一个字母(部门)时,而不是 ALL ,例如,部门A中的名称将显示在下面的列表中,只显示其具体名称显示所选下拉列表中该特定元素的部门值。我该如何解决这个问题?
答案 0 :(得分:1)
您可以尝试使用下面提到的过滤器来解决问题。另请使用此plunker链接检查您的示例工作方案。
<强>模板:强>
import pandas as pd
import matplotlib.pyplot as plt
# Create a data frame from the list
a = pd.DataFrame([5,6,-1,-1, 8,3,5,7,3,6,-1,3,8,5])
b=a.copy()
b[2]=b[0].shift(1,axis=0)
b[4]=(b[0]!=-1) & (b[2]==-1)
b[5]=b[4].shift(-1,axis=0)
b[0] = (b[5] | b[4])
c=b[0]
d=pd.DataFrame(c)
# Prepare a boolean mask
mask = a > 0
# New data frame with missing values filled with the last element of
# the previous segment. Choose 'bfill' to use the first element of
# the next segment.
a_masked = a[mask].fillna(method = 'ffill')
# Prepare the plot
fig, ax = plt.subplots()
line, = ax.plot(a_masked, 'b:o', lw = 1)
ax.plot(a[mask], color=line.get_color(), lw=1.5, marker = 'o')
ax.plot(a_masked[d], color=line.get_color(), lw=1.5, marker = 'o')
plt.show()
<强>控制器:强>
ng-options="item as item.department for item in users | unique:'department'"