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에 목록에 있는 단어를 입력하게 되면 그 단어만 필터링해서 실시간으로 찾아주게 됩니다.
첨부파일
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 58 | jQuery Mobile | 8년 전 | 2988 | ||
| 57 | jQuery Mobile | 8년 전 | 2031 | ||
| 56 | jQuery Mobile | 8년 전 | 1367 | ||
| 55 | jQuery Mobile | 8년 전 | 1557 | ||
| 54 | jQuery Mobile | 8년 전 | 2239 | ||
| 53 | jQuery Mobile | 8년 전 | 1537 | ||
| 52 | jQuery Mobile | 8년 전 | 1559 | ||
| 51 | jQuery Mobile | 8년 전 | 1427 | ||
| 50 | jQuery Mobile | 8년 전 | 1317 | ||
| 49 | jQuery Mobile | 8년 전 | 1819 | ||
| 48 | jQuery Mobile | 8년 전 | 1462 | ||
| 47 | jQuery Mobile | 8년 전 | 2021 | ||
| 46 | jQuery Mobile | 8년 전 | 1982 | ||
| 45 | jQuery Mobile | 8년 전 | 1514 | ||
| 44 | jQuery Mobile | 8년 전 | 1676 | ||
| 43 | jQuery Mobile | 8년 전 | 1790 | ||
| 42 | jQuery Mobile | 8년 전 | 1668 | ||
| 41 | jQuery Mobile | 8년 전 | 1835 | ||
| 40 | jQuery Mobile | 8년 전 | 1479 | ||
| 39 | jQuery Mobile | 8년 전 | 1634 | ||
| 38 | jQuery Mobile | 8년 전 | 2182 | ||
| 37 | jQuery Mobile | 8년 전 | 2684 | ||
| 36 | jQuery Mobile | 8년 전 | 2133 | ||
| 35 | jQuery Mobile | 8년 전 | 1523 | ||
| 34 | jQuery Mobile | 8년 전 | 2425 | ||
| 33 | AngularJS | 8년 전 | 2874 | ||
| 32 | AngularJS | 8년 전 | 2437 | ||
| 31 | AngularJS | 8년 전 | 1767 | ||
| 30 | AngularJS | 8년 전 | 2843 | ||
| 29 | AngularJS | 8년 전 | 2401 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기