Skip to content

Instantly share code, notes, and snippets.

@jhines2k7
Created July 23, 2015 18:44
Show Gist options
  • Save jhines2k7/1955851ef914e14e9817 to your computer and use it in GitHub Desktop.
Save jhines2k7/1955851ef914e14e9817 to your computer and use it in GitHub Desktop.
An example of using AngularUI router with nested views with a resolve
<script>
angular.module('main', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
resolve: {
filterData: function(){
return [1, 2, 3, 4, 5, 6]
},
tableData: function(){
return {
foo: 'FOO',
bar: 'BAR'
}
},
graphData: function(){
return {
color: 'Red',
numDoors: 4
}
}
},
views: {
main: {
templateUrl: 'main.html',
controller: function($scope){
}
},
'filters@home': {
templateUrl: 'filters.html',
controller: function($scope, filterData) {
console.log('Filter data: ', filterData);
}
},
'tabledata@home': {
templateUrl: 'tabledata.html',
controller: function($scope, tableData) {
console.log('Table data: ', tableData);
}
},
'graph@home': {
templateUrl: 'graph.html',
controller: function($scope, graphData) {
console.log('Graph data: ', graphData);
}
}
}
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment