Angular has ng shortening for directives in markup, but how can I use that in js code. I mean when I write angular.isArray I'd prefer to write ng.isArray (as we do with jQuery ($), or Underscore (_)). Is it possible?
2 Answers
You can define var ng = angular; as a global variable, like JB Nizet suggested.
If you fear a conflict and prefer not to put anything in the global scope, you can wrap your code inside a Self-Executing Anonymous Function (closure) like this:
(function (ng) {
// declare a module
var myAppModule = ng.module('myApp', []);
// configure myAppModule.
// ...
})(angular);