# Code coverage report for ./src/ocLazyLoad.loaders.jsLoader.js

## Statements: 100% (12 / 12) Branches: 100% (0 / 0) Functions: 100% (7 / 7) Lines: 100% (12 / 12) Ignored: none

All files » ./src/ » ocLazyLoad.loaders.jsLoader.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    1

    1
    29

    28
    13
    13
    13

    13
    12

    1

    28

    28

     'use strict';

    (function (angular) {
        'use strict';

        angular.module('oc.lazyLoad').config(function ($provide) {
            $provide.decorator('$ocLazyLoad', function ($delegate, $q) {
                /**
                 * jsLoader function
                 * @type Function
                 * @param paths array list of js files to load
                 * @param callback to call when everything is loaded. We use a callback and not a promise
                 * @param params object config parameters
                 * because the user can overwrite jsLoader and it will probably not use promises :(
                 */
                $delegate.jsLoader = function (paths, callback, params) {
                    var promises = [];
                    angular.forEach(paths, function (path) {
                        promises.push($delegate.buildElement('js', path, params));
                    });
                    $q.all(promises).then(function () {
                        callback();
                    }, function (err) {
                        callback(err);
                    });
                };
                $delegate.jsLoader.ocLazyLoadLoader = true;

                return $delegate;
            });
        });
    })(angular);
    //# sourceMappingURL=data:application/json;base64,