0

I'm trying to split data inside ng-repeat using ng-list which is not working

tr(ng-repeat='row in displayedCollection', style='padding:5px')
   td {{row.ID}}
   td 
     span(data-ng-hide="editMode") {{row.SOME[0]}}
     select.form-control.trkatn(name="SOME", data-ng-model="row.SOME", data-ng-show="editMode", ng-list=":", ng-trim="false")

here data in displayedCollection is coming from database using ajax and the values are somewhat like below example

[{ ID: '023YHZ', SOME: 'Value12 1448883027057'},
 {ID: '023NHZ', SOME: 'Value32 1448883027057'},
 {ID: '023YJZ', SOME: 'Value23 1448883027057'}]

now I want to extract value12 from some and other.

i tried doing it however it is showing 1st character of SOME if I use row.SOME[0] and full SOME value if I use row.SOME i.e Value12 1448883027057 for an example

1 Answer 1

1

You will have to split the string first

row.SOME.split(' ') 
>['Value12','1448883027057']
row.SOME.split(' ')[0]
>'Value12'
row.SOME.split(' ')[1]
>'1448883027057'
Sign up to request clarification or add additional context in comments.

2 Comments

oh great that worked, however can you please tell me how it is working inside {{}}
The docs on expressions should clear things up. Essentially you can do most javascript things in angular expressions, such as call String.split.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.