在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);
};
});
})();
这在非缩小/构建的应用程序上效果很好。但是,当我使用foundation build
构建应用程序时,我在控制台中收到以下错误:
错误:[$injector:unp]未知提供程序:eProvider<-e<-滚动指令
我是否缺少任何东西使此指令在缩小的应用程序上有效?
您必须在指令中使用与控制器中使用的相同的缩小安全依赖项注入语法。控制器中也缺少一些注入字符串:
(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);
};
}]);
})();