angularjs filter (not working)

前端 未结 7 1335
灰色年华
灰色年华 2020-12-25 14:56

The following HTML, Javascript and JSON render correctly, but the filter does not work at all. What are we doing wrong?



        
7条回答
  •  無奈伤痛
    2020-12-25 15:47

    Angular filters cannot handle an object of objects as input, however, to resolve the issue you are facing, you can add a watch to the catalog_filter. As follows:

    $scope.$watch('catalog_filter', function (value) {
            regex = new RegExp($scope.catalog_filter);
             if (!$scope.catalog_filter) return true;
             return regex.test(catalog.uid); /* can create multiple conditions based on the requirement*/
        });
    

    Doing this the filter acts on the input text and filters when the text changes.

提交回复
热议问题