【发布时间】:2017-04-04 08:43:58
【问题描述】:
有一个关于在不同模块中引用和注入指令的问题。目标是将位于不同文件中的多个指令注入一个模块,然后将该公共模块注入其他地方。我有多个指令,在单独的文件中定义,例如:
define(['angular'], function (angular) {
angular.module('ngCustomDirective')
.directive('ngCustomDirective', function () {
...
});
});
在单独的文件中,我有:
define(['angular'], function (angular) {
angular.module('ngCustomDirective2')
.directive('ngCustomDirective2', function () {
...
});
});
之后该指令在另一个模块(不同的文件)中被引用:
define(['angular','ngCustomDirective', 'ngCustomDirective2'], function (angular, ngCustomDirective, ngCustomDirective2) {
angular.module('directives', [ngCustomDirective, ngCustomDirective2]);
return 'directives';
});
接下来,这个“指令”模块被注入到另一个模块中。上面的代码不起作用。我在这里做错了什么?
【问题讨论】:
标签: angularjs angularjs-directive angularjs-scope