Javascript 角度ng绑定html内部ng重复

Javascript 角度ng绑定html内部ng重复,javascript,html,angularjs,Javascript,Html,Angularjs,与 我有这个工作的html代码 <div class="modal modal-wide fade" id="indexHTML" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="but

  • 我有这个工作的html代码

    <div class="modal modal-wide fade" id="indexHTML" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">index.html</h4>
                </div>
                <div class="modal-body">
    
                <pre><code class="language-markup" ng-bind-html="indexHTML"></pre></code>
    
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    
    
    &时代;
    index.html
    
    接近 因为我需要多次使用此代码,所以我决定使用ng repeat,而不是复制粘贴

    function getSourceCode(object, property, url) {
        $http.get(url).then(function(response) {
            object[property] = response.data.replace(/</g,"&lt;");
        }).catch(console.error.apply(console));
    }
    
    
    &时代;
    {{modal.fileName}
    
    接近 我犯了这个错误,我想不出来

    此外,我发现许多人建议使用$sce.trustAsHtml(),但在我的例子中,在我尝试使用ng repeat之前,我的ng bind html与ngSanitize完美配合,所以我真的想用它来解决我的问题吗

    更新


    我不知道为什么,但当我不使用ng repeat时,我需要手动替换“
    ng bind html
    接受一个表达式。因此它应该类似于
    ng bind html=“modal.html”
    。不
    {}

    我不知道为什么,但当我不使用ng repeat时,我需要手动替换“我已经尝试过了,但这样它就不会引用html的内容。在我的例子中,如果我使用ng bind而不是ng bind html,它可以完美地工作,但它们将替换ex的html部分。”
    function getSourceCode(object, property, url) {
        $http.get(url).then(function(response) {
            object[property] = response.data.replace(/</g,"&lt;");
        }).catch(console.error.apply(console));
    }
    
    function getSourceCode(object, property, url) {
        $http.get(url).then(function(response) {
            object[property] = response.data.replace(/</g,"&lt;");
        }).catch(console.error.apply(console));
    }