각도 js에서 필터를 사용하여 인스턴트 검색을 구현하려고합니다. 나는 "찾을 수 없음!" 필터가 비어있을 때, 즉 일치하는 결과가 없을 때 표시되는 메시지. ng-hide
필터 배열이 비어있을 때 지시자는 작동하지 않습니다.
<!DOCTYPE html>
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body ng-controller="places as p">
<div>
<input type="text" ng-model="cname" />
<div ng-repeat="country in abc=(p.countries|filter:cname)">
<h1>{{country.name}}</h1>{{abc.length}}
<span ng-hide="abc.length">Not Found!!</span>
</div>
</div>
<script>
var app = angular.module('myApp', []);
var arr = [{
name: 'germany'
}, {
name: 'mexico'
}, {
name: 'india'
}, {
name: 'UK'
}, {
name: 'argentina'
}];
app.controller('places', function() {
this.countries = arr;
});
</script>
</body>
</html>
ng-hide
외부 이동이 ng-repeat
효과가 있었다 !!
<input type="text" ng-model="cname" />
<div ng-repeat="country in abc=(p.countries|filter:cname)">
<h1>{{country.name}}</h1>{{abc.length}}
</div>
<span ng-hide="abc.length">Not Found!!</span>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다