Here is the code for my simple searchController:
testapp.controller("searchController", function($scope, $rootScope, $http, $location) {
$scope.filterText = null;
var load = function() {
console.log('call load()...');
var url = 'product.json';
if($rootScope && $rootScope.appUrl) {
url = $rootScope.appUrl + '/' + url;
}
console.log(url);
$http.get(url)
.success(function(data, status, headers, config) {
$scope.product = data;
angular.copy($scope.product, $scope.copy);
});
}
load();
});
In the view, I have declared a filterText variable and it looks like this:
<div class="container main-frame" ng-app="testapp"
ng-controller="searchController" ng-init="init()">
<h1 class="page-header">Products</h1>
<!-- Filter Start -->
<div class="search-box row-fluid form-inline">
<label>Filter: </label> <input type="text" ng-model="filterText" />
</div>
<div class="results-top"></div>
<!-- Filter End -->
<table class="table">
<thead>
<tr>
<th width="25px">ID</th>
<th>TITLE</th>
<th>PRICE</th>
<th>Description</th>
<th width="50px"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="p in product track by p.id | filter: filterText">
<td>{{p.id}}</td>
<td>{{p.title}}</td>
<td>{{p.price}}</td>
<td>{{p.description}}</td>
</tr>
</tbody>
</table>
<!-- ng-show="user.username" -->
<p>
</div>
I am facing an issue where nothing happens when I input text into the filter. Any suggestions on how to resolve this problem?
Your help is appreciated!