-2

I've tried to inject $q in my controller like this:

app.controller('NodeCtrl', ['Tree', function(Tree, $scope, $element, $q) {

But, $q is not defined, how can I start using it? I am using Angular 1.4

Samir Sabri
  • 937
  • 3
  • 11
  • 26

1 Answers1

2

You need to inject it as well as add it to your argument list:

app.controller('NodeCtrl', ['Tree', '$scope', '$element', '$q', 
               function(Tree, $scope, $element, $q) {
seanhodges
  • 17,426
  • 15
  • 71
  • 93
  • Thanks, it worked, however, I wonder why all those down votes for the question! I feel as the community is getting a little bit paranoid – Samir Sabri Jun 15 '15 at 11:22
  • It's unfortunate some people down vote without commenting how to improve the question. It might be the wording in the title; something like "How do I inject '$q' into my controller?" might be a bit more specific and also encourage people to read on. – seanhodges Jun 15 '15 at 11:37
  • Thanks seanhodges, I will try to be more thoughtful when writing the next question – Samir Sabri Jun 15 '15 at 11:46