2015-07-06 43 views
1

我写在下面的方式指令:角缩小安全

  • 指令的.html(模板)
  • DirectiveController .js文件(控制器)
  • 指令的.js(指令)

DirectiveController.js:

function DirectiveController($scope) {} 

Directive.js:

someModule.directive('directive', function() { 
    return { 
     restrict: 'E', 
     templateUrl: 'Directive.html', 
     controller: DirectiveController, 
     scope: { 
      data: '=' 
     } 
    } 
}); 

的问题是,我该怎么再缩小DirectiveController?提前

someModule.controller('someController',['$scope', function($scope) {} ]); 

感谢

回答

2

使用$inject “注释”: 我不能使用

DirectiveController.$inject = ['$scope']; 
function DirectiveController($scope) { 
    ... 
} 

是的,你可以的 “注释” 功能之前。

+0

如果我理解正确,我可以写: DirectiveController。$ inject = ['$ scope']; 函数DirectiveController($ s){ }; ____它将第一个参数理解为注入的$ scope? –

+0

是的,这是正确的。 –

+0

谢谢,我会试试看。将更新结果。 –