Skip to content

Instantly share code, notes, and snippets.

@stevenh77
Created November 5, 2014 19:52
Show Gist options
  • Save stevenh77/fac16bee4b44b8e70362 to your computer and use it in GitHub Desktop.
Save stevenh77/fac16bee4b44b8e70362 to your computer and use it in GitHub Desktop.
(function () {
'use strict';
angular
.module('app.common.router')
.directive('stBreadcrumbs', stBreadcrumbs);
function stBreadcrumbs($rootParams) {
var directive = {
restrict: 'E',
contoller: function($scope) {
var rootUrl = "#/";
$scope.crumbs = [{ url: rootUrl, text: 'Home' }];
var runningUrl = rootUrl;
for (var param in $rootParams) {
runningUrl += $routeParams[param];
$scope.crumbs.push({ url: runningUrl, text: $routeParams[param] });
}
$scope.notLast = function(crumb) {
return crumb !== _.last($scope.crumbs);
}
},
templateUrl: 'app/common/router/stBreadcrumbs.html',
};
return directive;
}
})();
<!-- html template file: app/common/router/stBreadcrumbs.html -->
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li ng-repeat="crumb in crumbs">
<h3>
<a href="{{crumb.url}}">{{crumb.text}}</a>
<span class="divider" ng-show="notLast(crumb)"> / </span>
</h3>
</li>
</ul>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment