Skip to content

Instantly share code, notes, and snippets.

@xrd
Created October 19, 2012 14:58
Show Gist options
  • Select an option

  • Save xrd/3918662 to your computer and use it in GitHub Desktop.

Select an option

Save xrd/3918662 to your computer and use it in GitHub Desktop.
appmod = angular.module( "mymodule", [] )
appmod.config [ '$httpProvider', ($httpProvider) ->
authToken = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers.common[ 'X-CSRF-TOKEN' ] = authToken
$httpProvider.responseInterceptors.push ( $q ) ->
( promise ) ->
success = (response) ->
_gaq.push(['_trackPageview', response.config.url]) if _gaq?
response
failure = (response) ->
$q.reject(response)
promise.then success, failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment