nothing but `angular` is global.

To make your thing work you need to do:

Application.Controllers.controller("XXX", ['$scope', '$q', function($scope,
$q) {

...

}]);

Note that this is not an endorsement of the apparent structure of your
application.

Typically, I chain all definitions off of the module object instead of
making them global, as in:

angular.module('module.name', ['module.dependency'])
.controller('ControllerName', ['$scope', '$q', function ($scope, $q) {
 ...
}])
.factory( ... );


On Thu, May 15, 2014 at 12:00 PM, Chris <[email protected]> wrote:

> I guess I don't understand where $q comes from.  I thought you would have
> full access just like $ if you in jQuery.
> Even if I do something like this, it has to be defined somewhere else?
>
> Application.Controllers.controller("XXX", ['$scope', '$q'],
> function($scope, $q) {
>
>
>
>
>
> On Thursday, May 15, 2014 11:51:25 AM UTC-4, Chris Rhoden wrote:
>
>> You aren't injecting $q, because your injection annotation does not
>> include it.
>>
>>
>> On Thu, May 15, 2014 at 11:46 AM, Chris <[email protected]> wrote:
>>
>>> hi all,
>>>
>>> i'm new to angularjs, trying to use $q in a controller with no luck.
>>>  any ideas?
>>> thanks
>>>
>>> TypeError: Cannot read property 'defer' of undefined
>>>
>>>
>>> Application.Controllers.controller("XXX", ['$scope'], function($scope,
>>> $q) {
>>>
>>> $scope.myFunc = function(){
>>>  var defer = $q.defer(),
>>> myPromise;
>>>
>>> myPromise = $scope.getData()
>>>  .then($scope.getData2)
>>> .then(function(data) {
>>> defer.resolve(); // resolve our defer
>>>         });
>>>  // return our promise
>>> return defer.promise();
>>>  }
>>> });
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> chrisrhoden
>>
>  --
> 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.
>



-- 
chrisrhoden

-- 
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.

Reply via email to