我使用的是lodash --一个JavaScript实用程序库--和我的AngularJS代码。
<div ng-repeat="question in questions">
<label>{{question | startCase}}</label>
</div>这是startCase https://lodash.com/docs#startCase的文档。
我有很多问题-大约1000个。如果一个问题有单词FAQS,它应该显示为FAQs。我该怎么做?
发布于 2015-06-05 10:04:25
您可以通过这样的过滤器来实现这一点:
app.filter('fixFAQ', function () {
return function (input) {
return input.replace('FAQS', 'FAQs');
};
});然后在startCase:{{question | startCase | fixFAQ}}之后使用
https://stackoverflow.com/questions/30663474
复制相似问题