앵귤러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을 보면 앵귤러에서 함수를 만드는 방법을 알 수 있습니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 58 | jQuery Mobile | 8년 전 | 2978 | ||
| 57 | jQuery Mobile | 8년 전 | 2023 | ||
| 56 | jQuery Mobile | 8년 전 | 1353 | ||
| 55 | jQuery Mobile | 8년 전 | 1546 | ||
| 54 | jQuery Mobile | 8년 전 | 2229 | ||
| 53 | jQuery Mobile | 8년 전 | 1527 | ||
| 52 | jQuery Mobile | 8년 전 | 1551 | ||
| 51 | jQuery Mobile | 8년 전 | 1420 | ||
| 50 | jQuery Mobile | 8년 전 | 1308 | ||
| 49 | jQuery Mobile | 8년 전 | 1814 | ||
| 48 | jQuery Mobile | 8년 전 | 1458 | ||
| 47 | jQuery Mobile | 8년 전 | 2014 | ||
| 46 | jQuery Mobile | 8년 전 | 1974 | ||
| 45 | jQuery Mobile | 8년 전 | 1509 | ||
| 44 | jQuery Mobile | 8년 전 | 1670 | ||
| 43 | jQuery Mobile | 8년 전 | 1781 | ||
| 42 | jQuery Mobile | 8년 전 | 1659 | ||
| 41 | jQuery Mobile | 8년 전 | 1829 | ||
| 40 | jQuery Mobile | 8년 전 | 1466 | ||
| 39 | jQuery Mobile | 8년 전 | 1627 | ||
| 38 | jQuery Mobile | 8년 전 | 2174 | ||
| 37 | jQuery Mobile | 8년 전 | 2677 | ||
| 36 | jQuery Mobile | 8년 전 | 2126 | ||
| 35 | jQuery Mobile | 8년 전 | 1514 | ||
| 34 | jQuery Mobile | 8년 전 | 2413 | ||
| 33 | AngularJS | 8년 전 | 2858 | ||
| 32 | AngularJS | 8년 전 | 2426 | ||
| 31 | AngularJS | 8년 전 | 1759 | ||
| 30 | AngularJS | 8년 전 | 2834 | ||
| 29 | AngularJS | 8년 전 | 2386 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기