Created
November 4, 2014 23:00
-
-
Save pc-pdx/30e60c1cf4f9b6eb5bf8 to your computer and use it in GitHub Desktop.
debug-directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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}}' ⇘</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