this is a silly question, but should I wish to return all instances of $stateProvider.state
in my app.js (my AngularJS config file) how would I go about this? For example when I used the ngRoute
I could do something like this in my .run()
block:
.run(function ($route) {
var someArray = [];
angular.forEach($route.routes, function (route, path) {
if (route.someKey) {
console.log(path); // do something with route.someKey!!!
someArray.push(route.someKey);
}
});
});
However, in my app I am using the ui-router
and I can't do something similar with $state
? I'm currently reading up on this but if anyone has a quick answer let me know!
Found it! $state.get()
works! I must have missed this before in the docs!
$state.get()
will output an object array, I run console.log($state.get);
and I get:
[
{
"name": "",
"url": "^",
"views": null,
"abstract": true
},
{
"abstract": true,
"template": "<ui-view/>",
"name": "app"
},
{
"url": "/login",
"templateUrl": "login/views/login.html",
"controller": "LoginCtrl",
"publicAccess": true,
"name": "app.login"
},
{
"abstract": true,
"url": "/home",
"templateUrl": "home/views/home-wrapper.html",
"controller": "HomeCtrl",
"name": "app.loggedInHome"
}
]
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