0

Im using youtube json api and it returns the viewcount as a string, but i need to sort it as an number. How could i do this without going thru the whole model and converting strings to ints?

json snippet

yt$hd: Object
yt$statistics: Object
favoriteCount: "0"
viewCount: "1443"
__proto__: Object

and im invoiking sorting like

orderBy:'yt$statistics.viewCount'

1 Answer 1

1

Not that firmilar with Angular, but I'd assume that orderBy parameter can take a function in place of a string like Lo-Dash does with its `sortBy() function. In which case you'd probably want something like this:

orderBy: function(obj){
  return ~~obj.yt$statistics.viewCount
}
Sign up to request clarification or add additional context in comments.

Comments

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.