The function below defines a variable in the rootscope.
function MyCtrl($scope, $rootScope) {
$rootScope.buttons = [{href: '#/students', icon:'icon-ok'},
{href: '#/students', icon:'icon-remove'},
{href: '#/students/new', icon:'icon-plus'}];
}
MyCtrl.$inject = ['$scope', '$rootScope'];
The html in the directive below depends upon a variable in the rootscope -
angular.module('btnbar.directive', []).
directive("btnBar", function(){
return {
restrict: 'E',
scope :{},
controller: function($scope, $element,$rootScope) {
},
template:'<div class="btn-toolbar">' +
'<a class="btn" ng-repeat="b in buttons" href={{b.href}}>' +
'<i class={{b.icon}}></i></a></div>',
replace:true
}
});
However the above code doesnt work. It works if I directly define the 'buttons' var in the directive scope.