-1

入力型検索の要素があります。私はこれにフィルタを適用することができません。Angular JS Filterがng-repeatに適用されていません

<label class="item-input-wrapper" style="font-size:20px!important;"> 
    <i class="icon ion-ios-search placeholder-icon"></i> 
    <input type="search" style="width:45%;font-size:20px!important;" placeholder=" Search" ng-model="searchText.text"> 
</label> 

ここで、この場合のフィルタは、私がng-ifを使用していないかのように、私は、フィルタを適用することができる午前ところ、適用されていません。 ng-ifを削除したくないため、私は何か理由を持ってお手伝いしてください。

<div class="w-clearfix product-row" ng-show="isListViewShown" **ng-repeat="product in arrayOfProducts | 
     filter : searchText.text " ng-if="$index % 4 === 0">** 
         <div class="_4-col" ng-if="$index < 
     arrayOfProducts.length"> 
          product.name 

    </div> 
</div> 

答えて

1

お試しください。

angular.module('myApp', []).controller('ctrl', function($scope) { 
 

 
$scope.searchText = ''; 
 

 
$scope.names = ['India','America','Japan','Denmark','Russia','Landon','Cuba','Finland','Italy','Shrilanka','Australia','Brazil','Canada']; 
 
}); 
 
<html> 
 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> 
 
<body> 
 
<div ng-app="myApp" ng-controller="ctrl"> 
 
<input type="search" ng-model="searchText" /> 
 
<ul> 
 
    <li ng-repeat="x in names | filter : searchText" ng-if="$index % 4 === 0"> 
 
    {{ x }} 
 
    </li> 
 
</ul> 
 
</div> 
 

 

 
</body> 
 
</html>

関連する問題