html
ng-click="selectCategory(item)"
控制器
$scope.selectCategory = function (newCategory) {
$scope.bottomValue = newCategory;
selectedCategory = newCategory;
$scope.selectedPage = 1;
}
$scope.categoryFilterFn = function (product) {
return selectedCategory == null ||
product.category == selectedCategory;
}
我的下面有类别过滤器控制器,它可以正常工作并正确过滤数组,但是当没有选择任何类别时,没有选择不需要的对象
目标:我希望在没有选择类别时显示数组中的所有值
例如请注意,从下方删除$scope.bottomValue
时,将返回数组中的所有对象。
$scope.edition_products = $filter('filter')( $scope.filteredItems, {approved: true, category: $scope.bottomValue});
注意:我不能使用过滤器执行此视图,但我想要这个有效的控制器端。
答案 0 :(得分:0)
您可以将条件更新为
return product.approved && (!selectedCategory || product.category == selectedCategory);
您甚至可能希望在那里添加@Html.DropDownList("DocumentListID", null, htmlAttributes: new { @class = "form-control")
<script>
$("#DocumentListID").change(function(){
alert($(this).val();
});
</script>
Swift3