앵귤러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을 보면 앵귤러에서 함수를 만드는 방법을 알 수 있습니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 208 | 부트스트랩 | 8년 전 | 2716 | ||
| 207 | AngularJS | 8년 전 | 1460 | ||
| 206 | AngularJS | 8년 전 | 1109 | ||
| 205 | AngularJS | 8년 전 | 984 | ||
| 204 | AngularJS | 8년 전 | 1385 | ||
| 203 | AngularJS | 8년 전 | 1182 | ||
| 202 | AngularJS | 8년 전 | 1499 | ||
| 201 | AngularJS | 8년 전 | 1447 | ||
| 200 | AngularJS | 8년 전 | 1418 | ||
| 199 | AngularJS | 8년 전 | 1344 | ||
| 198 | AngularJS | 8년 전 | 1225 | ||
| 197 | AngularJS | 8년 전 | 1388 | ||
| 196 | AngularJS | 8년 전 | 1043 | ||
| 195 | AngularJS | 8년 전 | 1251 | ||
| 194 | AngularJS | 8년 전 | 1267 | ||
| 193 | AngularJS | 8년 전 | 1613 | ||
| 192 | AngularJS | 8년 전 | 1358 | ||
| 191 | AngularJS | 8년 전 | 1580 | ||
| 190 | AngularJS | 8년 전 | 1548 | ||
| 189 | AngularJS | 8년 전 | 1640 | ||
| 188 | AngularJS | 8년 전 | 1394 | ||
| 187 | AngularJS | 8년 전 | 1366 | ||
| 186 | AngularJS | 8년 전 | 1397 | ||
| 185 | AngularJS | 8년 전 | 1433 | ||
| 184 | AngularJS | 8년 전 | 1476 | ||
| 183 | AngularJS | 8년 전 | 1467 | ||
| 182 | AngularJS | 8년 전 | 1007 | ||
| 181 | AngularJS | 8년 전 | 1385 | ||
| 180 | AngularJS | 8년 전 | 1275 | ||
| 179 | AngularJS | 8년 전 | 1247 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기