我的问题是,我找不到任何关于此的官方文档。https://docs.angularjs.org/guide/directive未注明建议controller: ['$scope', function($scope) {为什么我不能在$这里省略s,就像在link function(scope, elem, attrs) {?controller: ['scope', function(scope) {将导致错误"Error: [$injector:unpr] Unknown provider: scopeProvider <- scope这里的语法是什么?
3 回答
慕的地8271018
TA贡献1796条经验 获得超4个赞
有关所谓的官方文档
directive definition object
可以在$ reference for $ compile中找到。的
directive controller constructor function
是注射用当地人$scope
,$element
,$attrs
和$transclude
。注入这些。因此,他们的确切拼写很重要。创建
directive controller
通道controller:function($scope) {}
与创建通道相同controller:['$scope', function(scope) {}]
。
添加回答
举报
0/150
提交
取消