Using UIRouter in an Angular 1.5 app, I'm having trouble trying to set an initial state for my angular module.
I've created a few states without URLs (because I don't need actual routing) and I would like to activate an initial state once the module is instantiated.
Usually, I would do this using $urlRouterProvider.otherwise(<initialRoute>), but since I don't use URLs in my states, that can't work.
Does UIRouter (or Angular) provide a solution for this?
After your application has bootstrapped, you can set your initial state inside the .run() method.
angular.module("myModuleName")
.run([
"$state",
function($state){
$state.go('stateName');
}
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With