Getting "Unknown provider: $qProvider <- $q" when fetching the defer/promise from my AngularJS injector -


i trying create simple example promise/defer object angularjs's service solution:

var $q;  function init() {      var $injector = window.angular.injector();     console.log($injector);     $injector.invoke(["$q", function (_$q) {         console.log($q);         $q = _$q;     }]);  }  init(); 

but results in:

error: unknown provider: $qprovider <- $q [break on error]
throw error("unknown provider: " + path.join(' <- '));

what have missed?

you have add module provider resides in this:

var $injector = window.angular.injector(['ng']); 

then work!

edit: regarding 'ng' module, docs says must explicitly added. from angular injector docs:

modules – {array.<string|function>} – list of module functions or aliases. see angular.module. ng module must explicitly added. 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -