AngularJS Filters 사용자 입력을 기반으로 배열 필터링
AngularJS Filters 사용자 입력을 기반으로 배열 필터링
사용자 입력을 기반으로 배열 필터링
ng-model입력 필드에 지시문을 설정하여 입력 필드의 값을 필터의 표현식으로 사용할 수 있습니다.
입력 필드에 문자를 입력하면 목록에 따라 일치 / 축소됩니다.
<div ng-app="myApp" ng-controller="namesCtrl">
<p><input type="text" ng-model="test"></p>
<ul>
<li ng-repeat="x in names | filter : test">
{{ x }}
</li>
</ul>
</div>
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="namesCtrl">
<p>Type a letter in the input field:</p>
<p><input type="text" ng-model="test"></p>
<ul>
<li ng-repeat="x in names | filter:test">
{{ x }}
</li>
</ul>
</div>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>The list will only consists of names matching the filter.</p>
</body>
</html>
이미지와 같은 화면에서
input box에 목록에 있는 단어를 입력하게 되면 그 단어만 필터링해서 실시간으로 찾아주게 됩니다.
사용자 입력을 기반으로 배열 필터링
ng-model입력 필드에 지시문을 설정하여 입력 필드의 값을 필터의 표현식으로 사용할 수 있습니다.
입력 필드에 문자를 입력하면 목록에 따라 일치 / 축소됩니다.
<div ng-app="myApp" ng-controller="namesCtrl">
<p><input type="text" ng-model="test"></p>
<ul>
<li ng-repeat="x in names | filter : test">
{{ x }}
</li>
</ul>
</div>
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="namesCtrl">
<p>Type a letter in the input field:</p>
<p><input type="text" ng-model="test"></p>
<ul>
<li ng-repeat="x in names | filter:test">
{{ x }}
</li>
</ul>
</div>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>The list will only consists of names matching the filter.</p>
</body>
</html>
이미지와 같은 화면에서
input box에 목록에 있는 단어를 입력하게 되면 그 단어만 필터링해서 실시간으로 찾아주게 됩니다.
첨부파일
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 118 | jQuery Mobile | 8년 전 | 1340 | ||
| 117 | jQuery Mobile | 8년 전 | 1589 | ||
| 116 | jQuery Mobile | 8년 전 | 1817 | ||
| 115 | jQuery Mobile | 8년 전 | 1774 | ||
| 114 | jQuery Mobile | 8년 전 | 1960 | ||
| 113 | jQuery Mobile | 8년 전 | 1872 | ||
| 112 | jQuery Mobile | 8년 전 | 2482 | ||
| 111 | jQuery Mobile | 8년 전 | 1785 | ||
| 110 | jQuery Mobile | 8년 전 | 1578 | ||
| 109 | jQuery Mobile | 8년 전 | 1736 | ||
| 108 | jQuery Mobile | 8년 전 | 1964 | ||
| 107 | jQuery Mobile | 8년 전 | 1767 | ||
| 106 | jQuery Mobile | 8년 전 | 1445 | ||
| 105 | jQuery Mobile | 8년 전 | 1741 | ||
| 104 | jQuery Mobile | 8년 전 | 2407 | ||
| 103 | jQuery Mobile | 8년 전 | 1559 | ||
| 102 | jQuery Mobile | 8년 전 | 1499 | ||
| 101 | jQuery Mobile | 8년 전 | 1681 | ||
| 100 | jQuery Mobile | 8년 전 | 1916 | ||
| 99 | jQuery Mobile | 8년 전 | 1372 | ||
| 98 | jQuery Mobile | 8년 전 | 1391 | ||
| 97 | jQuery Mobile | 8년 전 | 1653 | ||
| 96 | jQuery Mobile | 8년 전 | 1307 | ||
| 95 | jQuery Mobile | 8년 전 | 1124 | ||
| 94 | jQuery Mobile | 8년 전 | 1522 | ||
| 93 | jQuery Mobile | 8년 전 | 1146 | ||
| 92 | jQuery Mobile | 8년 전 | 1563 | ||
| 91 | jQuery Mobile | 8년 전 | 1510 | ||
| 90 | jQuery Mobile | 8년 전 | 1678 | ||
| 89 | jQuery Mobile | 8년 전 | 1663 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기