[英]Error: Unexpected token punc «)», expected punc «,» while minifying angularjs app
I am trying to minify my app.js code (tried several online tools). 我正在尝试缩小我的app.js代码(尝试了几种在线工具)。 But I get the error mentioned in the question.
但是我得到了问题中提到的错误。 Here's my code:
这是我的代码:
(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]"));
}
}
})
}])();
What am I doing wrong? 我究竟做错了什么?
I think you want this 我想你要这个
(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]"));
}
};
}])
})();
You had the closing square bracket for your directive constructor in the wrong place. 您的指令构造函数的右括号放在错误的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.