1

在 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:unpr] 未知提供者:eProvider <- e <- scrollDirective

我是否缺少使该指令适用于缩小应用程序的任何内容?

4

1 回答 1

3

您必须在指令中使用与控制器中使用的相同的缩小安全依赖注入语法。控制器中还缺少一些注入字符串:

(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);
        };
    }]);
})();
于 2016-05-03T15:45:31.637 回答