0

I am trying to minify my app.js code (tried several online tools). 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?

3
  • the '[' before you function tag is the problem .. Commented Nov 11, 2015 at 4:13
  • 1
    @KishoreSahas not quite but the braces and square brackets definitely seem mismatched Commented Nov 11, 2015 at 4:15
  • I just realised I didn't add '$window' just before my function. Commented Nov 11, 2015 at 4:16

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.