Commit 45aca914 authored by Evren Kutar's avatar Evren Kutar

change breadcrumb when route changes

links will be implemented
parent 9755bc35
......@@ -54,12 +54,12 @@ app.directive('headerBreadcrumb', function ($location) {
templateUrl: 'shared/templates/directives/header-breadcrumb.html',
restrict: 'E',
replace: true,
link: function($scope){
$scope.$watch('$routeUpdate', function(){
link: function($scope, $rootScope){
//$scope.$watch('$routeUpdate', function(){
// todo: create actual links
//debugger;
$scope.links = $location.path().split('/');
});
//$scope.links = $location.path().split('/');
//$scope.links = $rootScope.links;
//});
}
}
});
......@@ -75,13 +75,22 @@ app.directive('sidebar', ['$location', function () {
$rootScope.loggedInUser, function(){
$http.post(RESTURL.url + 'crud/').success(function (data) {
$scope.menuItems = data.app_models;
// at start define breadcrumblinks for breadcrumb
angular.forEach(data.app_models, function (value, key) {
angular.forEach(value[1], function (v, k) {
if(v[1] == $location.path().split('/')[1]){
$rootScope.breadcrumblinks = [value[0], v[0]];
}
});
});
});
}
);
// todo: change to $watch to init
$timeout(function(){
$('#side-menu').metisMenu();
}, 1000);
}, 500);
$scope.selectedMenu = $location.path();
$scope.collapseVar = 0;
......@@ -93,6 +102,12 @@ app.directive('sidebar', ['$location', function () {
$scope.collapseVar = 0;
else
$scope.collapseVar = x;
};
// breadcrumb function changes breadcrumb items and itemlist must be list
$scope.breadcrumb = function(itemlist){
$rootScope.breadcrumblinks = itemlist;
};
$scope.multiCheck = function (y) {
......@@ -102,6 +117,9 @@ app.directive('sidebar', ['$location', function () {
else
$scope.multiCollapseVar = y;
};
},
link: function(){
$('#side-menu').metisMenu();
}
}
}]);
......
<ul class="breadcrumb">
<li ng-repeat="link in links" ng-class="{'active':$last}">
<li ng-repeat="link in $root.breadcrumblinks" ng-class="{'active':$last}">
<a href="#" ng-if="!$last">{{link}}</a>
<span ng-if="$last">{{link}}</span>
</li>
......
......@@ -12,7 +12,7 @@
<a href="" ng-click="check($index+1)"><i class="fa fa-wrench fa-fw"></i> {{ item[0] }}<span
class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li ng-repeat="(k, v) in item[1]"><a href="#/{{v[1]}}">{{v[1]}}</a></li>
<li ng-repeat="(k, v) in item[1]"><a href="#/{{v[1]}}" ng-click="breadcrumb([item[0], v[0]])">{{v[1]}}</a></li>
</ul>
<!-- /.nav-second-level -->
</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment