I\'m creating an ajax search page which will consist of a search input box, series of filter drop-downs and then a UL where the results are displayed.
As the filters
In your HTML, you need to reference a property defined on your controller's $scope. One way to do that is to bind $scope.searchService.results
to searchService.results
once in your controller:
$scope.searchService.results = searchService.results;
Now this line will work:
-
In your service, use angular.copy()
rather than assigning a new array reference to results
, otherwise your controller's $scope will lose its data-binding:
var new_results = [{ 'title': 'title 3' },
{ 'title': 'title 4' }];
angular.copy(new_results, results);
Fiddle. In the fiddle, I commented out the initial call to find(), so you can see an update happen when you type something into the search box.