我正在使用这个例子
我做的完全一样,但我收到以下错误
angular.js:14525 Error: [$injector:unpr] Unknown provider: $elementProvider <- $element <- DragulardndCtrl
http://errors.angularjs.org/1.6.4/$injector/unpr?p0=%24elementProvider%20%3C-%20%24element%20%3C-%20DragulardndCtrl
at angular.js:66
at angular.js:4789
at Object.getService [as get] (angular.js:4944)
at angular.js:4794
at getService (angular.js:4944)
at injectionArgs (angular.js:4969)
at Object.instantiate (angular.js:5015)
at $controller (angular.js:10881)
at Object.link (angular-route.js:1214)
at angular.js:1346 "<div ng-view="" class="ng-scope">"
我已经用 yeoman angular 生成了项目。代码如下
Controller :
angular.module('dragdropApp')
.controller('DragulardndCtrl', ['$scope', '$element', 'dragularService', function TodoCtrl($scope, $element, dragularService) {
$scope.items1 = [{
content: 'Move me, but you can only drop me in one of these containers.'
}, {
content: 'If you try to drop me somewhere other than these containers, I\'ll just come back.'
}, {
content: 'Item 3'
}, {
content: 'Item 4'
}];
$scope.items2 = [{
content: 'Item 5'
}, {
content: 'Item 6'
}, {
content: 'Item 7'
}, {
content: 'Item 8'
}];
var containers = $element.children().children();
dragularService([containers[0],containers[1]],{
containersModel: [$scope.items1, $scope.items2]
});
}])
HTML:查看
<div class='tableRow'>
<div class='containerVertical'>
<div ng-repeat="item in items1">{{item.content}}</div>
</div>
<div class='containerVertical'>
<div ng-repeat="item in items2">{{item.content}}</div>
</div>
</div>
<div class="tableRow">
<div class="container">
<div>Items1:
<br/>{{items1 | json}}</div>
</div>
<div class="container">
<div>Items2:
<br/>{{items2 | json}}</div>
</div>
</div>
我使用了与上述链接完全相同的代码。
提前致谢