I'm trying to wait for the provider to finish initializing before ui-router goes on to load the state.
Every time you enter the state the camera should be enabled, and whenever it is left disabled again. I put this into a provider because it needs to be usable at the module.config
level:
.provider("Camera", function CameraProvider() {
function init() {
//async enableCamera
}
function exit() {
//disableCamera
}
function $get() {
return { init: init, exit: exit };
}
});
and the state:
var cam = DubCameraProvider.$get(); // this is a hack, but I don't know how to
$stateProvider
.state("CameraState", {
url: "/camera",
onEnter: cam.init,
onExit: cam.exit,
views: {
"view": {
// template: ...,
controller: "ControllerUsingCamera"
}
}
I tried using $q
to create a promise and the using resolve
to wait for that, but at the module.config
level $q cannot be injected (or I just don't know how to?).
How can I solve this?