Hi all,
I am unable to access the filter array I am passing the result of an ng-repeat into.My code looks like below, with the intention of being able to access the filtered array both in the HTML and the controller for other uses.
index.html:
<li ng-repeat="item in filtered = (items | filter:input.searchInput)"><h4>{{item.title}}</h4><p>{{item.content}}</p></li>
<p>{{filtered.length}} matches found</p>
app.js
.state('main.itemsPage', {
url: "/items",
views: {
'itemsContainer':{
templateUrl: "templates/items.html",
controller: "itemsCtrl",
resolve:{
items:[ '$http', function($http){
return $http.get('http://localhost/itemsTest/items.json').then(function(response){
return response.data;
})
}]
}
}
}
})
controller.js
.controller('itemsCtrl', function($scope, $state, items, $ionicScrollDelegate){
$scope.input = {};
$scope.items= items;
console.log($scope.filtered)
}
The last line (console.log) returns undefined, and the binding in the index file to get the length of the array also yields nothing
Are you aware of anything that needs to be taken into consideration to make the filtered array accessible?