angularjs过滤“日期”和$ locale服务 [英] angularjs filter 'date' and $locale service

查看:215
本文介绍了angularjs过滤“日期”和$ locale服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,angularjs嵌入一些国际化的资源:


Angular支持日期,数字和货币过滤器的i18n / l10n。
此外,Angular通过ngPluralize指令支持本地化的多元化支持
。所有可本地化的Angular组件
都依赖于由locale服务管理的特定于locale的规则集。

如果发现 $ locale 服务,但不知道如何

以下代码:

  {{article.date_collected | date:'EEEE dd MMMM yyyy'}} 

给出:


2014年10月6日星期一

但是我想要:


Lundi 06 Octobre 2014


有什么建议?

解决方案

最后,我在角度github页面上找到了响应:
https://github.com/angular/bower-angular-i18n#bower-angular-i18n



编辑:更多信息为我工作



在您的根应用程序目录中,从bower安装资源

  bower install angular-i18n 

添加<$如果您使用bower / buildjs将所有脚本压缩到 vendor.js ,则在这些注释标记之间的c $ c>< script> c> file:

 <! -  endbower  - > 
< script src =bower_components / angular-i18n / angular-locale_fr-fr.js>< / script>
<! - endbuild - >

就是这样。


it seems that angularjs embed some internationalized resources:

Angular supports i18n/l10n for date, number and currency filters. Additionally, Angular supports localizable pluralization support through the ngPluralize directive. All localizable Angular components depend on locale-specific rule sets managed by the $locale service.

If found the $locale service but don't kwnow how to specify the locale in fr-fr...

The following code :

{{article.date_collected | date:'EEEE dd MMMM yyyy'}}

Gives :

Monday 06 October 2014

But I want :

Lundi 06 Octobre 2014

Any suggestions?

解决方案

Finally I found the response on the angular github page: https://github.com/angular/bower-angular-i18n#bower-angular-i18n

EDIT : more info for what worked for me

In your root app directory, install resources from bower

bower install angular-i18n

Add a <script> to your index.html between this comments tags if you use bower/buildjs to compact all your scripts to vendor.js file :

<!-- endbower -->
<script src="bower_components/angular-i18n/angular-locale_fr-fr.js"></script>
<!-- endbuild -->

That's it.

这篇关于angularjs过滤“日期”和$ locale服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆