I am using [jquery-pjax][1] in my project, where every screen is a mini
AngularJs application (no frontend routing). So when I load my content via
PJAX request, I manually compile the DOM:
angular.module('mainPageModule', ['commonComponentModule']);
angular.element(document).ready(function () {
var $injector = angular.injector(['ng', 'mainPageModule']);
$injector.invoke(function($rootScope, $compile, $document) {
$compile($document)($rootScope);
$rootScope.$digest();
});
});
My ```commonComponentModule``` is loaded on initial request (separate JS
file), where the common component of all modules are placed.
angular.module('commonComponentModule', []);
angular.module('commonComponentModule')
.directive('activeTab', ['$location', function ActiveTab ($location) {
return {
restrict: 'A',
scope: false,
link: function(scope, element, attrs) {
var path = $location.absUrl().split($location.host())[1];
console.log(path);
if(attrs.href.match('^' + path + '$')) {
element.addClass('is-active');
} else {
element.removeClass('is-active');
}
}
}
}]);
When I load the screen with this ```mainPageModule```, I get the following
[ERROR][2]:
```Unknown provider: $rootElementProvider <- $rootElement <- $location <-
activeTabDirective <- $location```
I get the same error, even if I remove the ```commonComponentModule``` and
add the ```activeTab``` directive to my ```mainPageModule```
[1]: https://github.com/defunkt/jquery-pjax
[2]:
https://docs.angularjs.org/error/$injector/unpr?p0=$rootElementProvider%20%3C-%20$rootElement%20%3C-%20$location%20%3C-%20activeTabDirective%20%3C-%20$location
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.