admin管理员组文章数量:1391934
I am new in angular js.
my array -
"cards":[
"xxx Bank Credit Card",
"yyy Bank Debit Card"
],
what i am tring get only xxx adn yyy or Credit and Debit from the string .I am using angular js 1.2.23 .
I am new in angular js.
my array -
"cards":[
"xxx Bank Credit Card",
"yyy Bank Debit Card"
],
what i am tring get only xxx adn yyy or Credit and Debit from the string .I am using angular js 1.2.23 .
Share Improve this question asked Sep 20, 2014 at 8:14 Himanshu BhuyanHimanshu Bhuyan 3062 gold badges8 silver badges20 bronze badges 2- You can do by creating custom filter.. – Jay Shukla Commented Sep 20, 2014 at 8:16
- 1 Possible duplicate of How to split a string with angularJS – Dave DuPlantis Commented Jun 15, 2017 at 18:15
2 Answers
Reset to default 1Try this
angular.module('myModule', [])
.filter('split', function() {
return function(input, splitChar, splitIndex) {
// do some bounds checking here to ensure it has that index
return input.split(splitChar)[splitIndex];
}
});
Use in view like
{{test | split(',',0)}}
Ref - See here
You can even use default Filter of Angular Js " limitTo() " . it is very helpful but not a splitter , https://docs.angularjs/api/ng/filter/limitTo
in your case you can use it like {{cards[0] | limitTo(3) }} =xxx
本文标签: javascriptHow to split string using angular jsStack Overflow
版权声明:本文标题:javascript - How to split string using angular js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744689877a2619929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论