How to watch for ng-model created with ng-bind-html

后端 未结 2 359
北荒
北荒 2020-12-10 16:26

I need some help with an ng-model created with ng-bind-html. I have a JSON file in the server in which I have some html and some inputs like this:

*.json

<         


        
2条回答
  •  有刺的猬
    2020-12-10 16:44

    javascript:

    app.controller('demoController', function($rootScope, $scope, $http, $compile){
    var arr = [
        '
    I am an HTMLstring with links! and other stuff
    ' ,'
    name:
    ' ,'
    age:
    ']; $scope.user={}; $scope.testChange2 = function(){ var compileFn = $compile( arr[Number.parseInt(Math.random()*10)%3] ); var $dom = compileFn($scope); $('#test').html($dom); }; });

    html:



    user:{{user}}

提交回复
热议问题