Javascript 带angularjs的FilterText

Javascript 带angularjs的FilterText,javascript,angularjs,angularjs-ng-repeat,angularjs-filter,Javascript,Angularjs,Angularjs Ng Repeat,Angularjs Filter,我有一个简单的搜索控制器: testapp.controller("searchController", function($scope, $rootScope, $http, $location) { $scope.filterText = null; var load = function() { console.log('call load()...'); var url = 'product.json'; if($r

我有一个简单的搜索控制器:

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();

}); 
如您所见,我已声明filterText。我的看法是:

<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>

产品
过滤器:
身份证件
标题
价格
描述
{{p.id}}
{{p.title}}
{{p.price}}
{{p.description}}

我的问题是,在输入内容时什么也没发生。有什么建议可以解决这个问题吗


谢谢你的回答

跟踪方式
表达式相关的问题

请尝试在
ng repeat
末尾添加
曲目:

<tr ng-repeat="p in product | filter: filterText track by p.id">

或者根本不通过
删除
跟踪

我使用正确的代码创建JSFIDLE。请参阅:


如果您提供JSfiddle/Plunker给我们,那就太棒了:)@ArtyomPranovich Thx作为您的答案!我在这里简化了我的工作:1。没有init()函数2。不要使用ng init 3。filterText为null&从不changes@FooL好,在plunker上更改了1和2。如何给filterText赋值?为什么不直接使用