<div ng-app> <div ng-controller="customerCtrl"> <h1>고객목록</h1> <ul> <li ng-repeat="customer in customerList"> [{{$index+1}}] 고객이름 : {{customer.name}}, 고객나이 : {{customer.age}} </li> </ul> <h2>18세 미만 고객</h2> <ul> <li ng-repeat="youngCuster in youngCusterList"> [{{$index+1}}] ㅗㄱ객이름 : {{youngCuster.name}}, 고객나이 : {{youngCuster.age}} </li> </ul> </div> </div>
var customerCtrl = function($scope){ var customerList = [ {name: '영화', age: 10}, {name: '순회', age: 28} ]; var youngCusterList = []; angular.forEach(customerList, function(value, key){ if(value.age < 18){ youngCusterList.push(value); } }); $scope.customerList = customerList; $scope.youngCusterList = youngCusterList; };