I have this service:
app.service("UserService", function(){
var userService = {};
userService.userInfo = [
{firstName: "John", lastName: "Doe"},
{firstName: "Carl", lastName: "Smith"}
];
return userService;
});
And I want to inject it into a .config to define routes (for which I'm using ui-router)
app.config(["userService", function($stateProvider, userService){
$stateProvider
.state("#",{
templateUrl: "index.html",
controller: "UserListController"
})
.state('users', {
url: '/user/:username',
templateUrl: "view/userProfile.html",
controller: "UserListController",
params: { username: userService.userInfo[0].firstName}
})
...
This isn't working properly. Any ideas on can I inject the data in that service to be accessed by the .config?
Thank you :)