Skip to content

Instantly share code, notes, and snippets.

@pc-pdx
Created November 4, 2014 23:00
Show Gist options
  • Save pc-pdx/30e60c1cf4f9b6eb5bf8 to your computer and use it in GitHub Desktop.
Save pc-pdx/30e60c1cf4f9b6eb5bf8 to your computer and use it in GitHub Desktop.
debug-directive
/**
* Show pretty datas for debugging purposes.
* ~USAGE:: <debug obj="nowPlayingApiResponse"></debug>
*/
.directive('debug', function () {
return {
restrict: 'E',
scope: {
expression: '=obj',
callersName: '@obj'
},
template: "<h5>'{{callersName}}' &seArr;</h5><pre>{{debug(expression)}}</pre>",
link: function (scope, iElement, iAttrs, ctrl) {
// pretty-prints
scope.debug = function (exp) {
return angular.toJson(exp, true);
};
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment