错误:意外的令牌punc«)»,预期的punc«,»同时缩小angularjs应用程序

时间:2015-11-11 04:10:24

标签: javascript angularjs minify

我正在尝试缩小我的app.js代码(尝试了几个在线工具)。但我得到了问题中提到的错误。这是我的代码:

(function() {
    var app = angular.module('LazyApp', []);
    app.directive('lazyLoad', ['$window', function($window) {
        return {
            restrict: 'A',
            scope : {},
            link: function(scope, element, attrs) {
                var images = Array.prototype.slice.call(element[0].querySelectorAll("img[data-src]"));
                var videos = Array.prototype.slice.call(element[0].querySelectorAll("iframe[data-src]"));
            }
        }
    })
}])();

我做错了什么?

1 个答案:

答案 0 :(得分:3)

我想你想要这个

(function() {
    angular.module('LazyApp', [])
    .directive('lazyLoad', ['$window', function($window) {
        return {
            restrict: 'A',
            scope : {},
            link: function(scope, element) {
                var images = Array.prototype.slice.call(element[0].querySelectorAll("img[data-src]"));
                var videos = Array.prototype.slice.call(element[0].querySelectorAll("iframe[data-src]"));
            }
        };
    }])
})();

你的指令构造函数的结束方括号位于错误的位置。

相关问题