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에 목록에 있는 단어를 입력하게 되면 그 단어만 필터링해서 실시간으로 찾아주게 됩니다.
첨부파일
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 88 | jQuery Mobile | 8년 전 | 1932 | ||
| 87 | jQuery Mobile | 8년 전 | 1912 | ||
| 86 | jQuery Mobile | 8년 전 | 1518 | ||
| 85 | jQuery Mobile | 8년 전 | 1831 | ||
| 84 | jQuery Mobile | 8년 전 | 1866 | ||
| 83 | jQuery Mobile | 8년 전 | 1882 | ||
| 82 | jQuery Mobile | 8년 전 | 1654 | ||
| 81 | jQuery Mobile | 8년 전 | 1370 | ||
| 80 | jQuery Mobile | 8년 전 | 1806 | ||
| 79 | jQuery Mobile | 8년 전 | 1355 | ||
| 78 | jQuery Mobile | 8년 전 | 1753 | ||
| 77 | jQuery Mobile | 8년 전 | 1779 | ||
| 76 | jQuery Mobile | 8년 전 | 1788 | ||
| 75 | jQuery Mobile | 8년 전 | 1399 | ||
| 74 | jQuery Mobile | 8년 전 | 1539 | ||
| 73 | jQuery Mobile | 8년 전 | 1246 | ||
| 72 | jQuery Mobile | 8년 전 | 1628 | ||
| 71 | jQuery Mobile | 8년 전 | 1621 | ||
| 70 | jQuery Mobile | 8년 전 | 1504 | ||
| 69 | jQuery Mobile | 8년 전 | 1511 | ||
| 68 | jQuery Mobile | 8년 전 | 2046 | ||
| 67 | jQuery Mobile | 8년 전 | 1315 | ||
| 66 | jQuery Mobile | 8년 전 | 1691 | ||
| 65 | jQuery Mobile | 8년 전 | 1183 | ||
| 64 | jQuery Mobile | 8년 전 | 1467 | ||
| 63 | jQuery Mobile | 8년 전 | 1655 | ||
| 62 | jQuery Mobile | 8년 전 | 1635 | ||
| 61 | jQuery Mobile | 8년 전 | 1875 | ||
| 60 | jQuery Mobile | 8년 전 | 1407 | ||
| 59 | jQuery Mobile | 8년 전 | 1964 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기