[英]Error: Unexpected token punc «)», expected punc «,» while minifying angularjs app
我正在嘗試縮小我的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]"));
}
}
})
}])();
我究竟做錯了什么?
我想你要這個
(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]"));
}
};
}])
})();
您的指令構造函數的右括號放在錯誤的位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.