Suppose I copy a string in a textarea, for example:
var str = "{ hello: 'world', places: ['Africa', 'America', 'Asia', 'Australia'] }";
So with JSON.parse(str)
I parsed the string in JSON format, but I would like to show the result in a textarea or something similar and formatted -
Also, if you modify something there and it's wrong, that's an error. Something similar to this web: link
My controller:
$scope.toParseJson= function (str) {
$scope.jsonValue = str;
}
$scope.validateJson= function (str) {
$scope.errors= JSON.parse(str);
}
My html
<textarea ng-change="toParseJson(str)" ng-model="str"></textarea><br>
{{errors}}<br>
<textarea ng-change="validateJson(str)" ng-model="jsonValue "></textarea>
1- How do I get in the second textarea to appear mending with their tabulations and differentiating?
2- Is there another elegant way to show the errors?