앵귤러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을 보면 앵귤러에서 함수를 만드는 방법을 알 수 있습니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 88 | jQuery Mobile | 8년 전 | 1924 | ||
| 87 | jQuery Mobile | 8년 전 | 1910 | ||
| 86 | jQuery Mobile | 8년 전 | 1515 | ||
| 85 | jQuery Mobile | 8년 전 | 1825 | ||
| 84 | jQuery Mobile | 8년 전 | 1863 | ||
| 83 | jQuery Mobile | 8년 전 | 1874 | ||
| 82 | jQuery Mobile | 8년 전 | 1647 | ||
| 81 | jQuery Mobile | 8년 전 | 1367 | ||
| 80 | jQuery Mobile | 8년 전 | 1804 | ||
| 79 | jQuery Mobile | 8년 전 | 1355 | ||
| 78 | jQuery Mobile | 8년 전 | 1750 | ||
| 77 | jQuery Mobile | 8년 전 | 1776 | ||
| 76 | jQuery Mobile | 8년 전 | 1783 | ||
| 75 | jQuery Mobile | 8년 전 | 1398 | ||
| 74 | jQuery Mobile | 8년 전 | 1535 | ||
| 73 | jQuery Mobile | 8년 전 | 1244 | ||
| 72 | jQuery Mobile | 8년 전 | 1626 | ||
| 71 | jQuery Mobile | 8년 전 | 1617 | ||
| 70 | jQuery Mobile | 8년 전 | 1500 | ||
| 69 | jQuery Mobile | 8년 전 | 1506 | ||
| 68 | jQuery Mobile | 8년 전 | 2038 | ||
| 67 | jQuery Mobile | 8년 전 | 1313 | ||
| 66 | jQuery Mobile | 8년 전 | 1690 | ||
| 65 | jQuery Mobile | 8년 전 | 1183 | ||
| 64 | jQuery Mobile | 8년 전 | 1465 | ||
| 63 | jQuery Mobile | 8년 전 | 1650 | ||
| 62 | jQuery Mobile | 8년 전 | 1628 | ||
| 61 | jQuery Mobile | 8년 전 | 1873 | ||
| 60 | jQuery Mobile | 8년 전 | 1402 | ||
| 59 | jQuery Mobile | 8년 전 | 1958 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기