0

In Java code I can easily convert bytearray into String like this:

byte[] data = {91, 123};
String string = new String(data);

But it is giving problems in doing the same with AngularJS in a data binding:

{{new String(data)}}

The above code is inside a HTML file of AngularJS code and the data is coming as a bytearray from an API call.

Hexaholic
  • 3,299
  • 7
  • 30
  • 39
sjain
  • 23,126
  • 28
  • 107
  • 185
  • http://stackoverflow.com/a/3195961 – eugene82 May 13 '15 at 10:11
  • the easiest is to convert the bytearray to string in the api call itself, and just use the string in the databinding – Sajan Chandran May 13 '15 at 10:19
  • Do you know the difference between Java and JavaScript? (Your post suggests you do, but just to be sure.) Also, can you change the API or are you just consuming it? – 11684 May 13 '15 at 10:37
  • @11684 - sorry, I don't know much about javascript. The api can be modified but I thought if there may be easy way to do it in angularjs itself as in java. Some restrictions are there because I am passing the bean object of API and in angularjs I am just retrieving the object properties by its getter methods so its difficult to change the object's getter method just for this change as I am using it in other files of my java application. – sjain May 13 '15 at 10:41
  • @SajanChandran - See above comment for the same reason. – sjain May 13 '15 at 10:44
  • I just wanted to ascertain you know that Java and JavaScript are two entirely different languages, you wouldn't be the first to ask a question on SO thinking that those are the same. What do you see when you try to `console.log()` the raw byte array (in JavaScript, of course)? What is its type? (`typeof data`) – 11684 May 13 '15 at 10:46

0 Answers0