我正在使用lodash
- 一个JavaScript实用程序库 - 使用我的AngularJS代码。
<div ng-repeat="question in questions">
<label>{{question | startCase}}</label>
</div>
这是startCase的文档 https://lodash.com/docs#startCase
我有很多问题 - 大约1000个问题。如果问题有FAQS
,则应显示为FAQs
。我怎么能这样做?
答案 0 :(得分:1)
你可以通过这样过滤来实现这个目标:
app.filter('fixFAQ', function () {
return function (input) {
return input.replace('FAQS', 'FAQs');
};
});
然后在startCase之后使用它:{{question | startCase | fixFAQ}}