这是我的傻瓜 - http://plnkr.co/edit/uqSB1gIz6XEmJfC8zHNb?p=preview
我正在尝试注入Angular Strap
index.html
包含正确的依赖关系并且顺序正确
按控制台说
Error: Unknown provider: $strap.directivesProvider <- $strap.directives <- notificationDirective
@http://code.angularjs.org/1.1.5/angular.min.js:29
c@http://code.angularjs.org/1.1.5/angular.min.js:27
@http://code.angularjs.org/1.1.5/angular.min.js:30
c@http://code.angularjs.org/1.1.5/angular.min.js:27
d@http://code.angularjs.org/1.1.5/angular.min.js:27
@http://code.angularjs.org/1.1.5/angular.min.js:37
forEach@[native code]
答案 0 :(得分:3)
AngularStrap的模块依赖项列在错误的位置。 '$strap-directives'
是模块依赖项,而不是服务依赖项,因此需要在应用程序引导期间列出,如:
var app = angular.module('myApp', ['$strap.directives']);
它还需要在指令中作为服务DI删除:
app.directive('notification', function(){
return {
restrict: 'E',
replace: true,
scope: {
ngModel: '='
},
template: '<div>Test</div>'
}
});
这也是他们在AngularStrap site上配置掠夺者的方式。
答案 1 :(得分:1)
$strap.directives
是一个模块。您需要将其定义为您自己模块的依赖项:
var app = angular.module('myApp', ['$strap.directives']);
您无需将此注入指令。因此,您的指令只会如下所示:
app.directive('notification', function(){
return {
restrict: 'E',
replace: true,
scope: {
ngModel: '='
},
template: '<div>Test</div>'
}
});