2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
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
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <script src="https://code.jquery.com/jquery-1.11.2.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
        <script src="../../dist/ocLazyLoad.js"></script>
 
    </head>
    <body>
        <div id="example" ng-app="LazyLoadTest" ng-controller="TestController"></div>
        <script>
            angular.module("LazyLoadTest", ["oc.lazyLoad"])
                .controller("TestController", function($scope, $ocLazyLoad, $compile) {
                    $ocLazyLoad.load("js/testApp.js").then(function() {
                        console.log('loaded!!');
                        var el, elToAppend;
                        elToAppend = $compile('<say-hello to="world"></say-hello>')($scope);
                        el = angular.element('#example');
                        el.append(elToAppend);
                    }, function(e) {
                        console.log('errr');
                        console.error(e);
                    })
                });
        </script>
    </body>
</html>