앵귤러js(angular.js) 필터 앵귤러js 테이블
* 앵귤러js(angular.js) 필터
필터에는 여러가지 있겠지만
1. uppercase : 알파벳을 대문자로 변경
2. lowercase : 알바벳을 소문자로 변경
3. currency : 화폐 단위로 변경
4. filter : 기준점을 바탕르로 배열을 필터
5. orderby : 기준점을 바탕으로 배열을 정렬
* 앵귤러js 테이블
테이블을 만들때 html에서와 동일하게 <tr></tr>태그를 써줘야 합니다.
<table></table> 테이블태그 안에는 밑에 태그들을 사용합니다.
<tr></tr> 테이블열
<td></td> 테이블 데이터
<th></th> 테이블 헤드
<html>
<head>
<title>앵귤러js Filter</title>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/angularsjs/1.3.14/angular.min.js"></script>
</head>
<body>
<div ng-app="mainApp" ng-controller="menuController>
<table border=0>
<tr>
<td>메뉴이름 : </td>
<td><input type="text" ng-model="menu.name"></td>
</tr>
<tr>
<td>가격 : </td>
<td><input type="text" ng-model="menu.price"></td>
</tr>
</table>
<table border=0>
<tr>
<td>메뉴 이름 대문자 : </td><td>{{menu.formatName() | uppercase}}</td>
</tr>
<tr>
<td>메뉴 이름 소문자 : </td><td>{{menu.formatName() | lowercase}}</td>
</tr>
<tr>
<td>가격 : </td><td>{{menu.price | currency : "\\"}}</td>
</tr>
<tr>
<td>메뉴판 : </td>
<td>
<ul>
<li ng-repeat="menuItem in menu.dishes | filter: name | orderby:'price'">
{{ menuItem.name + ', 가격 : ' + menuItem.price + '원'}}
</li>
</ul>
</td>
</tr>
</table>
</div>
<script>
var mainApp = angular.modeul("mainApp", []); //mainapp 객체 생성
mainApp.controller('menuController', function($scope){
$scope.menu={
name:"Wings and Beer",
price:'16000',
dishes:[
{name:'양념치킨', price:165000},
{name:'반반치킨', price:170000},
{name:'마늘치킨', price:180000}
],
formatName:function(){
var menuObject;
menuObject = $scope.menu;
return menuObject.name;
}
};
});
</script>
</body>
</html>
앵귤러 모듈이름은 mainApp라고 선언했고 Controller이름은 menuController라고 정의했습니다.
dishes에는 메뉴가 정렬되고 JSON형식으로 정의 했습니다.
formatName이라는 function을 보면 앵귤러에서 함수를 만드는 방법을 알 수 있습니다.
필터에는 여러가지 있겠지만
1. uppercase : 알파벳을 대문자로 변경
2. lowercase : 알바벳을 소문자로 변경
3. currency : 화폐 단위로 변경
4. filter : 기준점을 바탕르로 배열을 필터
5. orderby : 기준점을 바탕으로 배열을 정렬
* 앵귤러js 테이블
테이블을 만들때 html에서와 동일하게 <tr></tr>태그를 써줘야 합니다.
<table></table> 테이블태그 안에는 밑에 태그들을 사용합니다.
<tr></tr> 테이블열
<td></td> 테이블 데이터
<th></th> 테이블 헤드
<html>
<head>
<title>앵귤러js Filter</title>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/angularsjs/1.3.14/angular.min.js"></script>
</head>
<body>
<div ng-app="mainApp" ng-controller="menuController>
<table border=0>
<tr>
<td>메뉴이름 : </td>
<td><input type="text" ng-model="menu.name"></td>
</tr>
<tr>
<td>가격 : </td>
<td><input type="text" ng-model="menu.price"></td>
</tr>
</table>
<table border=0>
<tr>
<td>메뉴 이름 대문자 : </td><td>{{menu.formatName() | uppercase}}</td>
</tr>
<tr>
<td>메뉴 이름 소문자 : </td><td>{{menu.formatName() | lowercase}}</td>
</tr>
<tr>
<td>가격 : </td><td>{{menu.price | currency : "\\"}}</td>
</tr>
<tr>
<td>메뉴판 : </td>
<td>
<ul>
<li ng-repeat="menuItem in menu.dishes | filter: name | orderby:'price'">
{{ menuItem.name + ', 가격 : ' + menuItem.price + '원'}}
</li>
</ul>
</td>
</tr>
</table>
</div>
<script>
var mainApp = angular.modeul("mainApp", []); //mainapp 객체 생성
mainApp.controller('menuController', function($scope){
$scope.menu={
name:"Wings and Beer",
price:'16000',
dishes:[
{name:'양념치킨', price:165000},
{name:'반반치킨', price:170000},
{name:'마늘치킨', price:180000}
],
formatName:function(){
var menuObject;
menuObject = $scope.menu;
return menuObject.name;
}
};
});
</script>
</body>
</html>
앵귤러 모듈이름은 mainApp라고 선언했고 Controller이름은 menuController라고 정의했습니다.
dishes에는 메뉴가 정렬되고 JSON형식으로 정의 했습니다.
formatName이라는 function을 보면 앵귤러에서 함수를 만드는 방법을 알 수 있습니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 178 | AngularJS | 8년 전 | 1427 | ||
| 177 | AngularJS | 8년 전 | 1200 | ||
| 176 | AngularJS | 8년 전 | 1274 | ||
| 175 | AngularJS | 8년 전 | 1365 | ||
| 174 | AngularJS | 8년 전 | 1138 | ||
| 173 | AngularJS | 8년 전 | 1880 | ||
| 172 | AngularJS | 8년 전 | 1436 | ||
| 171 | AngularJS | 8년 전 | 1128 | ||
| 170 | AngularJS | 8년 전 | 1393 | ||
| 169 | AngularJS | 8년 전 | 1188 | ||
| 168 | AngularJS | 8년 전 | 1002 | ||
| 167 | AngularJS | 8년 전 | 1965 | ||
| 166 | AngularJS | 8년 전 | 1038 | ||
| 165 | AngularJS | 8년 전 | 1103 | ||
| 164 | AngularJS | 8년 전 | 1305 | ||
| 163 | AngularJS | 8년 전 | 1151 | ||
| 162 | AngularJS | 8년 전 | 1367 | ||
| 161 | AngularJS | 8년 전 | 1370 | ||
| 160 | AngularJS | 8년 전 | 1123 | ||
| 159 | AngularJS | 8년 전 | 1092 | ||
| 158 | AngularJS | 8년 전 | 1502 | ||
| 157 | AngularJS | 8년 전 | 1474 | ||
| 156 | AngularJS | 8년 전 | 1323 | ||
| 155 | AngularJS | 8년 전 | 1212 | ||
| 154 | AngularJS | 8년 전 | 1610 | ||
| 153 | AngularJS | 8년 전 | 1084 | ||
| 152 | AngularJS | 8년 전 | 1506 | ||
| 151 | AngularJS | 8년 전 | 1416 | ||
| 150 | AngularJS | 8년 전 | 1111 | ||
| 149 | AngularJS | 8년 전 | 1639 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기