Skip to content

Instantly share code, notes, and snippets.

@spacenick
Created July 30, 2014 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacenick/fc68438dfea71b9e4dc6 to your computer and use it in GitHub Desktop.
Save spacenick/fc68438dfea71b9e4dc6 to your computer and use it in GitHub Desktop.
$stateProvider
.state('items', {
abstract: true,
url: "/items",
resolve :{
items: ['DataSource', function(DataSource) {
return DataSource.fetchItems();
}]
}
})
.state('items.list', {
url: '',
controller: 'ListCtrl',
templateUrl: 'listTpl.html'
})
.state('items.details', {
url: '/:itemId',
resolve: {
item: ['items', '$stateParams', function(items, $stateParams){
// Puisque tu as déjà loadé toute la collection tu epux direct chopper l'objet
// Mais si tu veux tu peux faire une requête aussi (si tes objets sont pas complets par ex)
return items.find($stateParams.itemId);
}]
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment