Using angular. injector with ngAnimate
I have included "ngAnimate" as a dependency on my ngApp.
Now in the jQuery file I am trying to access it using:
angular.injector(['ng', 'angular-sm']).invoke(['$compile', '$timeout' ,function ($compile, $timeout) {
But it gives me an error
Error: $injector:unpr
Unknown Provider
Unknown provider: $rootElementProvider <- $rootElement <- $animate <- $compile
And then I changed this to:
angular.injector(['ng','ngAnimate', 'angular-sm']).invoke(['$compile', '$timeout' ,function ($compile, $timeout) {
angular.injector(['ng','ngAnimate', 'angular-sm']).invoke(['$animate','$compile', '$timeout' ,function ($animate,$compile, $timeout) {
And they are NOT USED.
Then I tried:
var app_element = document.querySelector('[ng-app=angular-sm]');
angular.element(app_element).injector().invoke(['$compile', '$timeout' ,function($compile,$timeout) {
I took the ngApp injector and it worked. Why is that?
+3
source to share