- I was asking for a slightly different thing than a simple json filter.
- value The value to convert to a JSON string.
- In addition to the angular json filter already mentioned, there is also the angular toJson() function .
- space Causes the resulting string to be pretty-printed.
- Then in your $watch (based on the answer to previous question) over the textarea model, can you do a console.log() and see what value you get in the string for the enter key – I think it’s “/n” – callmekatootie Apr 1 ’14 at 12:29
I have AngularJS application, which collects data from input, transforms model into string using JSON.stringify() and lets a user edit this model in such way that input fields get updated if the
element is updated and vice versa. Some kind of two-way binding :)
The problem is that the String itself looks ugly and I would like to format it so it looks like this:
And not like it looks now:
Any ideas how this can be acomplished? If you need some additional info – don’t hesitate asking. Every answer is highly appreciated and answered immidiately.
P.S. I guess this should be some kind of directive or a custom filter. Data itself SHOULD NOT be changed, only the output.