[英]Unknown provider for directive after build
On a Foundation For Apps web app, I have the following directive in my controller file to trigger some action on scroll: 在Foundation for Apps Web应用程序上,我的控制器文件中具有以下指令,以触发滚动操作:
(function() {
'use strict';
angular.module('application').controller('MeetingRoomsCtrl', ['$scope', '$timeout', 'facilities', 'items', '$state', '$window',
function($scope, $timeout, facilities, items, $state, $window, foundation, ModalFactory, NotificationFactory) {
// controller code ...
}
])
.directive('scroll', function($window, $document, $timeout) {
return function(scope, element, attrs) {
var grid_content = document.querySelectorAll('.grid-content')[0];
var stickyFunction = function() {
// doing stuffs ...
scope.$apply();
};
angular.element(grid_content).bind("scroll", stickyFunction);
};
});
})();
Which works great on non minified/built app. 在非缩小/内置的应用上效果很好。 But when I build the application using foundation build
, I get the following error in the console: 但是,当我使用foundation build
构建应用程序时,在控制台中出现以下错误:
Error: [$injector:unpr] Unknown provider: eProvider <- e <- scrollDirective 错误:[$ injector:unpr]未知提供程序:eProvider <-e <-scrollDirective
Am I missing anything to make this directive works on minified app? 我是否缺少任何使该指令在缩小版应用程序上起作用的东西?
You have to do use the same minification-safe dependency injection syntax in your directive that you are using in the controller. 您必须在您的控制器中使用与指令中相同的minification-safe依赖项注入语法。 Also there were some injection strings missing in the controller: 控制器中还缺少一些注入字符串:
(function() {
'use strict';
angular.module('application').controller('MeetingRoomsCtrl', ['$scope', '$timeout', 'facilities', 'items', '$state',
'$window', 'foundation', 'ModalFactory', 'NotificationFactory',
function($scope, $timeout, facilities, items, $state, $window, foundation, ModalFactory, NotificationFactory) {
// controller code ...
}
])
.directive('scroll', ['$window', '$document', '$timeout', function($window, $document, $timeout) {
return function(scope, element, attrs) {
var grid_content = document.querySelectorAll('.grid-content')[0];
var stickyFunction = function() {
// doing stuffs ...
scope.$apply();
};
angular.element(grid_content).bind("scroll", stickyFunction);
};
}]);
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.