Is it advisable to refrain from using the 'angular' global object within Controllers, Services, etc?
Suppose we want to call the function:
angular.isDefined(myVar)
How should we reference the 'angular' object?
Possible approaches:
1 Use it directly, accepting possible 'variable is not defined' warnings from IDEs
2 Refer to the 'angular' dependency in an AMD compliant manner
define([
'angular'
], function (angular) {
'use strict';
return ['$log', '$filter', function ($log, $filter) {
return {
// ... code ...
angular.isDefined(myVar);
};
}];
}
);
3 Reference 'angular' using the Angular specific method
module.factory('ang', function() { return angular; });
define([], function () {
'use strict';
return ['ang', '$log', '$filter', function (ang, $log, $filter) {
return {
// ... code ...
ang.isDefined(myVar);
};
}];
}
);
I personally prefer Option 3, but am open to suggestions on the best approach.