Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created September 24, 2015 20:51
Show Gist options
  • Select an option

  • Save dwelch2344/4bbc082eef2c2f07362d to your computer and use it in GitHub Desktop.

Select an option

Save dwelch2344/4bbc082eef2c2f07362d to your computer and use it in GitHub Desktop.
Nifty way to debug the interpolated templates for angularjs
$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