嘿伙计们我收到一个错误Error: $injector:modulerr
当我缩小 Angular JS 1 应用程序时,到目前为止,我已经研究过这是我调用依赖项的方式HomeController
但是我不确定我可能哪里出错了。我注意到这里有一些预先存在的问题,但是我找不到解决这个问题的答案。
我感觉对该控制器的依赖可能是问题所在:
function HomeController($http, $firebaseArray, $scope, $scrollArray) {
var vm = this;
var baseRef = new Firebase("https://racoon.firebaseio.com/yello");
vm.feeds = $scrollArray(baseRef, 'date');
vm.config = {
plugins: {
controls: {
autoHide: true,
autoHideTime: 1000
}
}
};
}
因为代码被缩小了,所以我猜测函数中调用的依赖项正在以某种方式被破坏。
所以我尝试将它们注入到函数下面:
HomeController.$inject = ['$http', '$firebaseArray', '$scope', '$scrollArray'];
这是我的应用程序的所有 JS,以防万一不是这个控制器导致了这种情况:
(function() {
'use strict';
angular
.module('thatsPulman', [
// Angular modules.
'ngSanitize',
// Third party modules.
'firebase',
// Custom modules.
'app.core'
])
})();
(function() {
'use strict';
angular.module('app.core', ['iso.directives', 'ngSanitize', 'linkify', 'angular-images-loaded', 'imagesLoaded', 'yaru22.angular-timeago','infinite-scroll','com.2fdevs.videogular', 'com.2fdevs.videogular.plugins.controls', 'com.2fdevs.videogular.plugins.overlayplay'], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
})();
(function() {
'use strict';
angular
.module('app.core')
.controller('HomeController', HomeController)
.factory('$scrollArray', scrollArray);
function HomeController($http, $firebaseArray, $scope, $scrollArray) {
var vm = this;
var baseRef = new Firebase("https://racoon.firebaseio.com/yello");
vm.feeds = $scrollArray(baseRef, 'date');
vm.config = {
plugins: {
controls: {
autoHide: true,
autoHideTime: 1000
}
}
};
}
HomeController.$inject = ['$http', '$firebaseArray', '$scope', '$scrollArray'];
function scrollArray($firebaseArray, $timeout) {
return function(baseRef, field) {
// create a special scroll ref
var scrollRef = new Firebase.util.Scroll(baseRef, field);
// generate a synchronized array with the ref
var list = $firebaseArray(scrollRef);
// store the scroll namespace on the array for easy ref
list.scroll = scrollRef.scroll;
list.scroll.next(10);
return list;
}}
})();
(function() {
'use strict';
angular
.module('app.core')
.directive('imagesLoaded', imagesLoaded)
.directive('scroll', scroll);
function imagesLoaded($timeout) {
return {
restrict: 'A',
link: function($scope, $elem, $attr) {
$timeout(function() {
$elem.isotope();
$elem.isotope('once', 'layoutComplete', function(isoInstance, laidOutItems) {
$elem.imagesLoaded(function() {
$elem.isotope('layout');
});
});
}, 0);
}
};
}
function scroll($window) {
return function(scope, element, attrs) {
angular.element($window).bind("scroll", function() {
if (this.pageYOffset >= 300) {
scope.showContent = true;
} else {
scope.showContent = false;
}
scope.$apply();
});
};
};
})();
(function() {
'use strict';
angular
.module('app.core')
.filter('instagramLink', instagramLink);
function instagramLink($filter, $sce) {
return function(text, target) {
if (!text) return text;
var replacedText = $filter('linky')(text, target);
var targetAttr = "";
if (angular.isDefined(target)) {
targetAttr = ' target="' + target + '"';
}
// replace #hashtags
var replacePattern1 = /(^|\s)#(\w*[a-zA-Z_]+\w*)/gim;
replacedText = replacedText.replace(replacePattern1, '$1<a href="https://www.instagram.com/explore/tags/$2"' + targetAttr + '>#$2</a>');
$sce.trustAsHtml(replacedText);
return replacedText;
};
};
})();
知道我哪里可能出错吗?谢谢