Hello,

i have an ng-repeat with a filter that is linked to a text field to filter 
the results

<h3>List <span ng-bind="filteredProducts.length"></span></h3>
<input type="text" ng-model="search.name" placeholder="name">
<div data-ng-repeat="product in filteredProducts =(products.productList | 
psearch:search.name)" class="productList">
//use the product info...
</div>


i have created a filter

.filter('psearch',function(){
    return function(element,searchname) {
        console.log("psearch called");
        console.log("element:",element);
        var out = [];
        angular.forEach(element, function(product) {

            if (product.naam.match(searchname)) {
                out.push(product);
            }
        });
        console.log("out",out); //this gives me an array with the number of 
items matching the result
        return out;
    }
});


this filter works and the "filteredProducts.length" in my span in the h3 
tag above gets updated with the number of results of the filter.

now i want to use this number in my controller but when i try to access it 
like

$scope.filteredProducts.length

i get an error cannot get length of undefined 

also when i check this with

console.log("filtered:",typeof $scope.filteredProducts);


i get:

filtered: undefined

how can i fix this?

thank

Marco




-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to