Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix when config is undefined. #50

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ angular.module('chieffancypants.loadingBar', [])
var cache;
var defaults = $httpProvider.defaults;

if (!config) {
return false;
}

if (config.method !== 'GET' || config.cache === false) {
config.cached = false;
return false;
Expand Down Expand Up @@ -97,7 +101,7 @@ angular.module('chieffancypants.loadingBar', [])
'request': function(config) {
// Check to make sure this request hasn't already been cached and that
// the requester didn't explicitly ask us to ignore this request:
if (!config.ignoreLoadingBar && !isCached(config)) {
if (config && !config.ignoreLoadingBar && !isCached(config)) {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
if (reqsTotal === 0) {
startTimeout = $timeout(function() {
Expand All @@ -111,7 +115,7 @@ angular.module('chieffancypants.loadingBar', [])
},

'response': function(response) {
if (!isCached(response.config)) {
if (response && 'config' in response && !isCached(response.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url});
if (reqsCompleted >= reqsTotal) {
Expand All @@ -124,7 +128,7 @@ angular.module('chieffancypants.loadingBar', [])
},

'responseError': function(rejection) {
if (!isCached(rejection.config)) {
if (rejection && 'config' in rejection && !isCached(rejection.config)) {
reqsCompleted++;
$rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url});
if (reqsCompleted >= reqsTotal) {
Expand Down