Why can I not use something like this?
<input type="text" ng-model="testVal">
<pre>{{JSON.stringify(testVal,null,4)}}</pre>
If I remove the JSON.stringify() method my code works just fine.
You can simply use | json
:
{{ testVal | json }}
or add JSON
to $scope
:
$scope.JSON = JSON
then
<pre>{{ JSON.stringify(testVal) }}</pre>
works