javascript 如何使用angular js拆分字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25946718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to split string using angular js
提问by Himanshu Bhuyan
I am new in angular js.
我是 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 .
我想从字符串中只得到 xxx adn yyy 或 Credit 和 Debit。我使用的是 angular js 1.2.23。
回答by Jay Shukla
回答by katmanco
You can even use default Filter of Angular Js " limitTo() " . it is very helpful but not a splitter , https://docs.angularjs.org/api/ng/filter/limitTo
您甚至可以使用 Angular Js 的默认过滤器“limitTo()”。它非常有用,但不是拆分器, https://docs.angularjs.org/api/ng/filter/limitTo
in your case you can use it like {{cards[0] | limitTo(3) }} =xxx
在您的情况下,您可以像 {{cards[0] | 一样使用它 limitTo(3) }} =xxx