ocLazyLoad:使用 ngSanitizer 时出错

ocLazyLoad: error using ngSanitizer

我想使用 angular 应用程序 ngSanitize 在我的应用程序中使用纯 HTML。我基本上想重现 here in the docs 解释的功能,但我想使用 ocLazyLoad 延迟加载模块。但出于某种原因,我仍然收到错误 Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context,表明 ngSanitize 未正确加载。

我是不是做错了什么或者这是一个错误?

这是一个缩小的例子:

<!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.3.7/angular.js"></script>
    <script src="ocLazyLoad.js"></script>
</head>
<body>
    <div id="example" ng-app="LazyLoadTest" ng-controller="TestController">
    <p ng-bind-html="myHTML"></p>
    </div>
    <script>
        angular.module("LazyLoadTest", [ "oc.lazyLoad"])
            .controller("TestController", function($scope, $ocLazyLoad, $compile){
                $ocLazyLoad.load({
                        name: "ngSanitize",
                        files: ["angular-sanitize.js"],
                        serie: true
                    }).then(function () {
                        $scope.myHTML =
                            'I am an <code>HTML</code>string with ' +
                            '<a href="#">links!</a> and other <em>stuff</em>';
                    }, function (e) {
                        console.log(e);
                    })
        });
    </script>
</body>
</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.3.7/angular.js"></script>
    <script src="angular-sanitize.js"></script>
</head>
<body>
    <div id="example" ng-app="LazyLoadTest" ng-controller="TestController">
    <p ng-bind-html="myHTML"></p>
    </div>
    <script>
        angular.module("LazyLoadTest", [ "ngSanitize"])
            .controller("TestController", function($scope){
                $scope.myHTML =
                            'I am an <code>HTML</code>string with ' +
                            '<a href="#">links!</a> and other <em>stuff</em>';
        });
    </script>
</body>
</html>

参见https://github.com/ocombe/ocLazyLoad/issues/176

显然 ngSanitizer 与 AngularJS 耦合得太紧密,无法延迟加载。

编辑:

请注意,现在 FAQ.

中也提到了这一事实