Angular Goodness – Display the JSON Object as a String for Debugging

During development, we always want to know the current status of the JSON Object, as this objects state keeps getting changed based on User actions as well as $http interaction.
AngularJS, has a built in filter called JSON which allows to convert the JSON object to String literal.
And combine this with html5 pre  and you have a powerful combination
 
/* Angular Controller */
Application.controller('TestCtrl',['$scope','$rootScope'function ($scope,$rootScope) {
$scope.userProfile
}
/* HTML5 Side */
<div ng-controller='TestCtrl'>
<pre {{userProfile | json}}>
</div>
view rawjsondebug hosted with ❤ by GitHub
originally published in 2014

Comments

Popular posts from this blog

Apache Airflow Wait Between Tasks

Hibernate Interview Questions

Java Spring Interview Questions