如何重置此angularjs过滤器 [英] How to reset this angularjs filter

查看:90
本文介绍了如何重置此angularjs过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 -



我正试图点击一下按钮来重置angularjs过滤器,但我尝试的任何东西似乎都没有用。单击该按钮时,应重置已选择的过滤器选项。我的代码产生过滤器未定义的错误。



这是代码

过滤器:

< pre lang =HTML> < div class = col-md-2 >
< 选择 class = < span class =code-keyword> form-control ng-model = typeFilter >
< 选项 value = > 所有< / option >
< 选项 > 股票< / option >
< 选项 > 特殊订单< / option >
< option > 部分< / option >
< / select >
< / div >
< div class = col-md-2 >
< 选择 class = form-control ng-model = itemStatus >
< 选项 value = > 所有< / option >
< 选项 > Active < / option >
< 选项 > 已停止< / option >
< 选项 < span class =code-keyword>> 已过时的< / option >
< 选项 < span class =code-keyword>> 已删除< / option >
< / select >
< / div >
< div class = col-md-2 >
< 按钮 type = button class = btn btn -large button-dropdown data-translate = Rest_Filters ng-click = vm.clearFilter() > 休息过滤器< / button >
< / div >



表格数据

< pre lang =HTML> < tbody >
< tr ng-repeat = 项目在vm中。物品| filter:{type:typeFilter ||全部} | filter:{status:itemStatus ||全部} >
< td ng-bind = item.itemNo > < ; / td >
< td ng-bind = item.description > < / td >
< td ng-bind = (item.listPrice |货币) > < / td >
< / tr >
< / tbody >





angularjs

 vm.clearFilter =  function ($ scope){

$ scope。 typeFilter = ;
}

< br $> b $ b

我尝试了什么:



我试过



vm.clearFilter = function($ scope){

$ scope.typeFilter =;

}

vm.clearFilter = function($ scope){

$ scope.typeFilt er = {};

}

vm.clearFilter = function($ scope){

$ scope.type = {};

}

ng-click =typeFilter = {}

解决方案

范围){


scope.typeFilter = ;
}





我尝试过:



我试过



vm.clearFilter = function(


scope){


Hi -

I'm trying to have a button click to reset the angularjs filters but nothing I have tried seems to work. When the button is clicked it should reset what ever filter options have already been chosen. The code I have produces an error of filter undefined.

Here is the code
Filters :

<div class="col-md-2">
    <select class="form-control" ng-model="typeFilter">
        <option value="">All</option>
        <option>Stock</option>
        <option>Special Order</option>
        <option>Part</option>
    </select>
</div>
<div class="col-md-2">
    <select class="form-control" ng-model="itemStatus">
        <option value="">All</option>
        <option>Active</option>
        <option>Discontinued</option>
        <option>Obsolete</option>
        <option>Deleted</option>
    </select>
</div>
<div class="col-md-2">
    <button type="button" class="btn btn-large button-dropdown" data-translate="Rest_Filters" ng-click="vm.clearFilter()"> Rest Filters</button>
</div>


Table data

      <tbody>
       <tr ng-repeat="item in vm.items | filter : {type : typeFilter || All} | filter:{status : itemStatus || All }">
             <td ng-bind="item.itemNo"> </td>
             <td ng-bind="item.description"></td>
             <td ng-bind="(item.listPrice | currency)"></td>
       </tr>
</tbody>



angularjs

vm.clearFilter = function ($scope) {

    $scope.typeFilter = "";
}



What I have tried:

I've tried

vm.clearFilter = function ($scope) {
$scope.typeFilter = "";
}
vm.clearFilter = function ($scope) {
$scope.typeFilter = {};
}
vm.clearFilter = function ($scope) {
$scope.type = {};
}
ng-click="typeFilter = {}"

解决方案

scope) {


scope.typeFilter = ""; }



What I have tried:

I've tried

vm.clearFilter = function (


scope) {


这篇关于如何重置此angularjs过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆