Skip to content

Instantly share code, notes, and snippets.

@HAKASHUN
Created October 17, 2013 06:40
Show Gist options
  • Save HAKASHUN/7020074 to your computer and use it in GitHub Desktop.
Save HAKASHUN/7020074 to your computer and use it in GitHub Desktop.
AngularJSでフィルタを作ってみる
<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>
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