Last active
August 29, 2015 14:06
-
-
Save codfish/d5fec94f4a40713aba13 to your computer and use it in GitHub Desktop.
AngularJS Breadcrumbs leveraging ui-router's states. Based off http://goo.gl/w0zFou
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
'use strict'; | |
/** | |
* App Module | |
* | |
* @note | |
* ui-router setup is def incomplete. this is just to show an | |
* example of the breadcrumb setup | |
* | |
* @ngInject | |
*/ | |
function config($stateProvider) { | |
$stateProvider | |
.state('home', { | |
url: '^', | |
breadcrumb: { | |
title: 'Home', | |
// example non-angular page, so provide physical url | |
// otherwise will use the state to link | |
url: '/' | |
} | |
}) | |
.state('home.articles', { | |
url: '/articles', | |
breadcrumb: { | |
title: 'Articles' | |
} | |
}) | |
.state('home.articles.view', { | |
url: '/:slug', | |
resolve: { | |
title: function() { | |
return 'Article title' | |
} | |
}, | |
breadcrumb: { | |
title: '{{ title }}' | |
} | |
}); | |
} | |
angular | |
.module('app', [ | |
'ui.router', | |
'app.breadcrumbs' | |
]) | |
.config(config); |
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
<div class="AppCtrl"> | |
<div data-breadcrumbs></div> | |
<!-- OR <div breadcrumbs></div> --> | |
<!-- OR <breadcrumbs></breadcrumbs> --> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment