AngularJs:给定月份数月的展会名称 [英] AngularJs: Show name of the month given the month number
本文介绍了AngularJs:给定月份数月的展会名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有每月一个数字(1,2,3,...),并想以显示相应的名称。
我怎样才能做到这一点?
I have the month as a number (1,2,3,...) and would like to display the corresponding name. How can I do this?
时有可能使用 {{date_ex pression |日期[:格式]}}
推荐答案
如果你有一个月的索引,你可以只创建您自己的过滤器:
If you have the month index, you could just create your own filter:
myApp.filter('monthName', [function() {
return function (monthNumber) { //1 = January
var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ];
return monthNames[monthNumber - 1];
}
}]);
然后在你的模板:
Then in your template:
{{date_expression | monthName}}
这篇关于AngularJs:给定月份数月的展会名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文