tlbApp.directive('breadcrumb', function ($location, $route) {
var breadcrumbDescriptionObject = {
restrict:'E',
priority:99,
replace:true,
transclude:true,
templateUrl:'views/breadcrumb.html',
link:function (_, iElement) {
var ul = angular.element(iElement.children()[0]);
var paths = $location.path().split('/');
var href = "#";
var path = "";
angular.forEach(paths, function (item) {
item=item.trim();
var last = paths.indexOf(item) == (paths.length - 1);
if (item=="" || (path[path.length-1]!='/')) {
path += '/';
}
path += item;
if($route.routes.hasOwnProperty(path)) {
var text = $route.routes[path].breadcrumb || item;
href += item + "/";
var lnk;
if (!last) {
lnk = "<li><a href='" + href + "'>" + text + "</a> <span class='divider'>></span></li>"
} else {
lnk = "<li class='active'>" + text + "</li>";
}
this.append(lnk);
}
}, ul);
}
};
return breadcrumbDescriptionObject;
});
tlbApp.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/', {
templateUrl:'views/welcome-page.html',
breadcrumb:'<i class="icon-home"></i>'
}).
when('/event/:id', {
templateUrl:'views/event-details.html',
controller:EventDetailController,
breadcrumb:'Évènement {}'
}).
otherwise({redirectTo:'/'});
}]);
I'd be interested in what you come up with. I had my own struggles yesterday with breadcrumbs and Pawel was a big help. I suspect that what you are trying to do is more along the lines of what I should have been doing.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
Hi,