亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Angepasste Anweisungen in ng-bind-html werden nicht wirksam!
天蓬老師
天蓬老師 2017-06-16 09:19:14
0
1
1028

Problem: Mit ng-bind-html wurde der richtige HTML-Code auf der Seite generiert, aber die Anweisung im Tag wird nicht wirksam!
js-Code:

HTML-Code:

天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~

Antworte allen(1)
劉奇

當(dāng)然無法生效,ng-bind-html 等同于 innerHTML

可以自定義一個(gè)類似 ng-bind-html-compile 的指令:

.directive('bindHtmlCompile', ['$compile', function ($compile) {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                scope.$watch(function () {
                    return scope.$eval(attrs.bindHtmlCompile);
                }, function (value) {
                    // In case value is a TrustedValueHolderType, sometimes it
                    // needs to be explicitly called into a string in order to
                    // get the HTML string.
                    element.html(value && value.toString());
                    // If scope is provided use it, otherwise use parent scope
                    var compileScope = scope;
                    if (attrs.bindHtmlScope) {
                        compileScope = scope.$eval(attrs.bindHtmlScope);
                    }
                    $compile(element.contents())(compileScope);
                });
            }
        };
    }]);
<p ng-bind-html-compile="getId(xxx)"></p>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage