Commit 9cc0e7a7 authored by Randall Leeds's avatar Randall Leeds

use angular 1.2+ intereptor pattern

parent 2440b74f
......@@ -39,12 +39,8 @@ class FlashProvider
]
angular.module('h.flash', ['ngResource'])
.provider('flash', FlashProvider)
.config(['$httpProvider', ($httpProvider) ->
$httpProvider.responseInterceptors.push ['$q', 'flash', ($q, flash) ->
(promise) ->
promise.then (response) ->
flashInterceptor = ['$q', 'flash', ($q, flash) ->
response: (response) ->
data = response.data
format = response.headers 'content-type'
if format?.match /^application\/json/
......@@ -59,5 +55,12 @@ angular.module('h.flash', ['ngResource'])
response
else
response
]
]
angular.module('h.flash', ['ngResource'])
.provider('flash', FlashProvider)
.factory('flashInterceptor', flashInterceptor)
.config(['$httpProvider', ($httpProvider) ->
$httpProvider.interceptors.push 'flashInterceptor'
])
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment