angularjspaginationdirpagination

How to category filter with AngularJS and dir-pagination


I am filtering and paging with dir-pagination. I want to filter with href. Pagination and filtering (search textbox) is working . But I want to link multi filtering type. link , textbox , combobox etc.

In main ctrl :

    $scope.currentPage = 1;
    $scope.pageSize = 10;
    $http.get('admin/api/?s=getProducts&lang='+lang).success(
    function(r){
    $scope.products = r;
        }
    );


function productFilter($scope) {
$scope.pageChangeHandler = function(num) {
console.log('going to page ' + num);
};
}

In Html Page:

        <div class="widget">
            <h4>CATEGORIES</h4>
            <div id="price-range">
                <div class="padding-range"><div id="slider-range"></div></div>
                <input type="text" style="background-color: #fff;border: 1px solid #D39797;  width: 140px; height: 22px;" ng-model="searchProduct">
                <a href="#" class="button light"   style="margin:0;">Search</a>
            </div>
            <div class="clearfix"></div>
        </div>


        <!-- Categories -->
        <nav class="widget" >
            <h4>Product Categories</h4>
            <ul class="categories" ng-repeat="category in categories">
                <li><a href="#"  ng-model="searchCategory = category.category" >{{category.category}}</a></li>
            </ul>
        </nav>

Solution

  • I added hidden input text and change value with ng-click event. Input will filter dir-paginate.

            <input type="hidden" ng-model="searchCategory" >    
            <!-- Categories -->
            <nav class="widget" >
                <h4>Product Categories</h4>
                <ul class="categories" ng-repeat="category in categories">
                    <li><a href ng-click="getProducCategory().searchCategory=category.category"  >{{category.category}}</a></li>
                </ul>
            </nav>
    

    Add getProductCategory() function to mainCtrl

    $scope.getProducCategory = function() {
         return $scope;   
        }