I have several dynamic pages that follow a simple query string pattern:
"...com/directory/my-post-title?id=#"
where hash is a digit defined in a JSON file, assigned at creation.
There are no issue with routing etc, and I have successfully been able to use this with ng-repeat to retrieve data when the exact match comparator is not present, but for some reason it does not work as expected when applied.
In the following setup, I am using a function within my filter to pull the query string from the url, which is then used to set the filter. Any reason why this isn't working?
Template:
<div data-ng-repeat="item in items | filter:{itemID:queryID}:true | limitTo:'1'">
{{::item.name}}
</div>
Controller:
angular.module('myApp').controller('mainCtrl', ['$rootScope', '$scope', '$location', function($rootScope, $scope, $location) {
$rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
$scope.queryID = $location.search().id;
});
}]);
JSON:
{
"myItems": [
{
"itemID": 1,
"name": "some name"
},
{
"itemID": 11,
"name": "another name"
}
]
}