angularjs - Errors is not printed out on resolve, ui-router -
let's have in module:
resolve: { user: function(userloader){ return new userloader($stateparams.userid); } } controller..
as can see, i've not injected $stateparams
, hence fail load controller , view. why console not giving errors on resolve everywhere else? can pain debug if have logic in resolve. possible "turn on" console on resolve somehow?
from documentation :
$statechangeerror - fired when error occurs during transition. it's important note if have errors in resolve functions (javascript errors, non-existent services, etc) not throw traditionally. must listen $statechangeerror event catch errors. use event.preventdefault() prevent $urlrouter reverting url previous valid location (in case of url navigation).
you must listen on '$statechangeerror' event
$rootscope.$on('$statechangeerror', function(event, tostate, toparams, fromstate, fromparams, error){ // error occured, $log.error(error) })
if want know more ui-router event, check api here
Comments
Post a Comment