Part of the AngularUI umbrella project
Karsten Sperling, Tim Kindberg, Jens Melgaard
Start at the begining of 2013
0.0.1 released in May 2013
In active development but surprisingly stable in 0.0.1
Nice new features already in master branch
$stateProvider & $state
A state corresponds to a "place" in the application
A state describes what the UI looks like and does at that place.
Controller & View
<!-- index.html -->
<body ng-controller="MainCtrl">
<div ui-view></div>
</body>
<!-- contacts.html -->
<h1>My Contacts</h1>
<div ui-view></div>
<!-- contacts.list.html -->
<ul>
<li ng-repeat="contact in contacts">
<a>{{contact.name}}
</li>
</ul>
$stateProvider
.state('contacts', {
templateUrl: 'contacts.html',
controller: function($scope){
$scope.contacts = [
{ name: 'Alice' },
{ name: 'Bob' }
];
}
})
.state('contacts.list', {
templateUrl: 'contacts.list.html'
});
function MainCtrl($state){
$state.transitionTo('contacts.list');
}
<body>
<div ui-view="filters"></div>
<div ui-view="tabledata"></div>
<div ui-view="graph"></div>
</body>
$stateProvider
.state('report', {
views: {
'filters': { ... templates, controllers, etc ... },
'tabledata': { ... },
'graph': { ... },
}
})
$stateProvider
.state('contacts.detail', {
views: {
// relatively targets the "info" view
"info" : { /* ... */ }
// relatively targets the unnamed view
"" : { /* ... */ }
// absolutely targets the "detail" view in parent
"detail@contacts" : { /* ... */ }
// absolutely targets the unnamed view in parent
"@contacts" : { /* ... */ }
// absolutely targets the "status" view in root
"status@" : { /* ... */ }
// absolutely targets the unnamed view in root
"@" : { /* ... */ }
});
<body>
<div ui-view="filters" ng-animate="'fade'"></div>
</body>
<ul>
<li ng-repeat="contact in contacts">
<a ui-sref="contacts.view({ id: contact.id })">
{{ contact.name }}
</a>
</li>
</ul>