Lazy Loading a service using oclazyload

By honey

This is index.html

<!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="node_modules/oclazyload/dist/ocLazyLoad.js"></script>
    <script src="testApp.js"></script>
</head>
<body>
<h3>Lazy load succeded if you can see 'Hello world' below</h3>
<div id="example" ng-app="LazyLoadTest" ng-controller="TestController">
    <button ng-click="fun()">Start</button>
</div>
<script>
    angular.module("LazyLoadTest", ["oc.lazyLoad"])
        .controller("TestController", function($scope, $ocLazyLoad, $compile) {
            $scope.fun=function(MyService){
                $ocLazyLoad.load("testApp.js").then(function() { //loading a module
                    console.log('loaded!!'+$scope);
                    var el, elToAppend,elToAppend2;
                    elToAppend = $compile('<say-hello to="world"></say-hello>')($scope); //appending it to div
                    el = angular.element('#example');
                    console.log(el);
                    el.append(elToAppend)
                    //el.append(elToAppend2);
                }, function(e) {
                    console.log('errr');
                    console.error(e);
                })
            }
        });
</script>
</body>
</html>

The above code is the module which is to be loaded at run time. Able to load Directive but need some help to load service.
How to laxyload the service defined in testApp.js?
Please help me out with this

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273