angular-ui / AngularJS-sublime-package

AngularJS code completion, snippets, go to definition, quick panel search, and more.
MIT License
1.42k stars 169 forks source link

bracket in directive definition #16

Closed lewis500 closed 11 years ago

lewis500 commented 11 years ago

Hi, I was curious why the directive snippet has an array like directive('', ['', function(){... when the documentation and most examples I've seen just have directive( " , function(){ ?

subhaze commented 11 years ago

Hi Lewis,

It's for dependency injection, more info can be found here http://docs.angularjs.org/guide/di

Example from link:

angular.module('myModule', []).
  config(['depProvider', function(depProvider){
    ...
  }]).
  factory('serviceId', ['depService', function(depService) {
    ...
  }]).
  directive('directiveName', ['depService', function(depService) {
    ...
  }]).
  filter('filterName', ['depService', function(depService) {
    ...
  }]).
  run(['depService', function(depService) {
    ...
  }]);