Created
September 24, 2015 20:51
-
-
Save dwelch2344/4bbc082eef2c2f07362d to your computer and use it in GitHub Desktop.
Nifty way to debug the interpolated templates for angularjs
This file contains hidden or 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
| $provide.decorator("$interpolate", function($delegate){ | |
| var interpolateWrap = function(){ | |
| var interpolationFn = $delegate.apply(this, arguments); | |
| if(interpolationFn) { | |
| return interpolationFnWrap(interpolationFn, arguments); | |
| } | |
| }; | |
| var interpolationFnWrap = function(interpolationFn, interpolationArgs){ | |
| return function(){ | |
| var result = interpolationFn.apply(this, arguments); | |
| var log = result ? console.log : console.warn; | |
| log.call(console, "interpolation of " + interpolationArgs[0].trim(), | |
| ":", result.trim()); | |
| return result; | |
| }; | |
| }; | |
| angular.extend(interpolateWrap, $delegate); | |
| return interpolateWrap; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment