Created
October 17, 2013 06:40
-
-
Save HAKASHUN/7020074 to your computer and use it in GitHub Desktop.
AngularJSでフィルタを作ってみる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body ng-controller="ShoppingController"> | |
<table> | |
<h1>Shop!</h1> | |
<tr ng-repeat="item in items"> | |
<td>{{item.title}}</td> | |
<td>{{item.description}}</td> | |
<!-- filter: yenを使用する --> | |
<td>{{item.price | yen}}</td> | |
</tr> | |
</table> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shoppingModule = angular.module( | |
'ShoppingModule', | |
[] | |
); | |
//yenという名前のフィルタを作成する。 | |
shoppingModule.filter('yen', function(){ | |
var yenFilter = function(input) { | |
var words = '¥'+ input; | |
return words; | |
}; | |
return yenFilter; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment