테스트 사이트 - 개발 중인 베타 버전입니다

AngularJS Filters 디렉 티브에 필터 추가

· 8년 전 · 1097
1.png
AngularJS Filters 디렉 티브에 필터 추가

[디렉 티브에 필터 추가]

필터는 ng-repeat파이프 문자 |와 필터 를 사용하여 지시문에 추가됩니다


orderBy필터 배열을 정렬한다 :

<div ng-app="myApp" ng-controller="namesCtrl">

<ul>
<li ng-repeat="x in names | orderBy:'country'">
{{ x.name + ', ' + x.country }}
</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>Looping with objects:</p>
<ul>
<li ng-repeat="x in names | orderBy:'country'">
{{ x.name + ', ' + x.country }}
</li>
</ul>

</div>

<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
{name:'Jani',country:'Norway'},
{name:'Carl',country:'Sweden'},
{name:'Margareth',country:'England'},
{name:'Hege',country:'Norway'},
{name:'Joe',country:'Denmark'},
{name:'Gustav',country:'Sweden'},
{name:'Birgit',country:'Denmark'},
{name:'Mary',country:'England'},
{name:'Kai',country:'Norway'}
];
});
</script>

</body>
</html>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
1547
1546
1545
1544
1542
1541
1540
1539
1538
1537
1535
1534
1533
1532
1531
1512
1508
1479
1478
1475
1474
1460
1459
부트스트랩 드롭 다운 헤더 7
1458
1457
1456
1455
1454
부트스트랩 부트스트랩 panel
1453
1452