Last active
August 29, 2015 14:14
-
-
Save johnpapa/ffce55d7cda11d52889e to your computer and use it in GitHub Desktop.
setting resolveAlways
This file contains 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
angular | |
.module('app.core') | |
.factory('cranker', cranker); | |
cranker.$inject = ['$http', '$log', '$q']; | |
function cranker($http, $log, $q) { | |
var data; | |
return { | |
go: function () { | |
if (!data) { | |
// pretend to go somewhere and return the data | |
$log.info('been cranking here'); | |
data = { | |
some: 'data' | |
}; | |
} | |
// must return a promise, which it would if we used the real $http | |
return $q.when(data); | |
} | |
}; | |
} | |
angular | |
.module('app.core') | |
.config(function (routerHelperProvider) { | |
routerHelperProvider.configure({ | |
docTitle: 'Cranking', | |
resolveAlways: { | |
ready: function (cranker) { | |
console.log('cranker was here'); | |
return cranker.go(); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment