Last active
August 29, 2015 14:05
-
-
Save anth12/802549c652e0e9a63be4 to your computer and use it in GitHub Desktop.
AngularJS Day of week filter
This file contains 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
angular.module('example').filter('dayOfWeek', function() { | |
return function(dayIndex) { | |
switch(dayIndex) { | |
case 0: | |
return 'Sunday'; | |
case 1: | |
return 'Monday'; | |
case 2: | |
return 'Tuesday'; | |
case 3: | |
return 'Wednesday'; | |
case 4: | |
return 'Thursday'; | |
case 5: | |
return 'Friday'; | |
case 6: | |
return 'Saturday'; | |
} | |
return ''; | |
} | |
}); |
This file contains 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
<div ng-app="example"> | |
<table> | |
<tr> | |
<td> | |
{{ model.day | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 0 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 1 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 2 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 3 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 4 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 5 | dayOfWeek}} | |
</td> | |
</tr> | |
<tr> | |
<td> | |
{{ 6 | dayOfWeek}} | |
</td> | |
</tr> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment