I am asking this question because I am not quite clear on how to think of rootscope as a dependency passed to directives
I have a directive that needs to display some in
Sometimes I have to use $scope.$root:
app.directive('setOrdinal', function() {
return {
link: function($scope, $element, $attr) {
var steps = $scope.$root.steps;
$scope.$watch(setOrdinal, function(value) {
if (value)
{
// steps code here
}
});
}
};
});
app.controller('stepController', ['$scope', '$rootScope', 'GetSteps', function ($scope, $rootScope, GetSteps) {
var s = $scope;
var r = $rootScope;
s.initialize = function(id)
{
GetSteps.get({id: id}, function(resp){
r.steps = resp.steps;
});
};
}]);