admin管理员组文章数量:1435859
I have an object profileObj.details[0].time which is equal to "10AM-4PM" I want to split this string into 10AM and 4PM .
please help to solve this issue. Thanks in advance
I have an object profileObj.details[0].time which is equal to "10AM-4PM" I want to split this string into 10AM and 4PM .
please help to solve this issue. Thanks in advance
Share Improve this question edited Nov 29, 2016 at 7:27 Ritesh Bhat asked Nov 29, 2016 at 7:26 Ritesh BhatRitesh Bhat 9761 gold badge20 silver badges32 bronze badges 1-
1
So use the string function
.split('-')
– Jes Commented Nov 29, 2016 at 7:26
1 Answer
Reset to default 5You can use .split
together with array destructuring
:
const [first, second] = "10AM-4PM".split('-');
console.log(first); // 10am
console.log(second); // 4pm
本文标签: javascriptSplit a string in AngularJs 2Stack Overflow
版权声明:本文标题:javascript - Split a string in AngularJs 2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745674916a2669794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论