我在谷歌搜索了很多,但我找不到任何问题。我的问题是如何过滤我的菜单选项值?我已将整个代码放在下面的位置。
http://plnkr.co/edit/q5WLaIvTN434o4nZNBdR
我有一个CSS菜单,其中包含href
个链接,但它位于不同的div
。那么如何根据菜单选择过滤我的结果呢?请帮帮我。
我的搜索框也隐藏在菜单下方。我试着给它z-index
。但它不起作用。怎么解决这个问题?
我的菜单div
如下:
<div id="menu-button">Menu</div>
<ul style="display:block;">
<li><a href='#' ng-click="menuFilter={}">Home</a></li>
<li id="deptMenu">
<a href='#'>Department</a>
<ul style="display: block;">
<li ng-repeat="dept in empDetails | unique:'department'">
<a href="" ng-click="menuFilter={department:'{{dept.department}}'}">{{dept.department}}</a>
</li>
</ul>
</li>
</ul>
</div>
但容器位于不同位置,如下所示:
<div class="container">
<div id="userlist" class="row">
<p data-ng-show="(empDetails | filter:searchTxt).length==0"><font color="red">There are no results for this search</font></p>
<div id="userDiv{{$index}}" class="shadow col-sm-1" ng-repeat="info in empDetails | filter:menuFilter | orderBy:'Name' | filter:searchTxt" tweenmax-animating-directive ng-click="openDetail()">
<div class="employeeDetail">
<div style="line-height:25px">
<b>{{info.Name}}</b><br/>
<b>number :</b>{{info.number}}<br/>
<b>Post :</b>{{info.post}}<br/>
</div>
</div>
</div>
</div>
</div>
我放置了&#34; menuFilter&#34;但这不起作用。
答案 0 :(得分:1)
只需保存所选部门的值并在过滤器中使用该值即可。因此,您的链接将更改为:
browser.switchTo().frame(element(by.className('daas-surface')));
<a href="" ng-click="selectDepartment(dept.department)">{{dept.department}}</a>
获取新字段,过滤器和方法:
$scope
$scope.selectedDepartment = null;
$scope.departmentFilter = function (info) {
return !$scope.selectedDepartment || info.department === $scope.selectedDepartment;
};
$scope.selectDepartment = function (dept) {
$scope.selectedDepartment = dept;
};
更改为:
ng-repeat
答案 1 :(得分:1)
您还可以查看此版本:http://plnkr.co/edit/CKdAnwB6Muh1j3ohkgFq 在您的菜单中:
<a href="" ng-click="setDept(dept)">{{dept.department}}</a>
在您的控制器中:
$scope.showDept = false;
$scope.dept = {};
$scope.setDept = function(d) {
$scope.dept = d;
$scope.showDept = true;
};
主容器中的ANd:
<div class="container">
<div id="userlist" class="row">
<p data-ng-show="(empDetails | filter:searchTxt).length==0"><font color="red">There are no results for this search</font></p>
<div id="userDiv{{$index}}" ng-show="showDept" class="shadow col-sm-1" tweenmax-animating-directive ng-click="openDetail()">
<div class="employeeDetail">
<div style="line-height:25px">
<b>{{dept.Name}}</b><br/>
<b>number :</b>{{dept.number}}<br/>
<b>Post :</b>{{dept.post}}<br/>
</div>
</div>
</div>
</div>
</div>