Created
July 23, 2015 18:44
-
-
Save jhines2k7/1955851ef914e14e9817 to your computer and use it in GitHub Desktop.
An example of using AngularUI router with nested views with a resolve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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