search

Home  >  Q&A  >  body text

angular.js - angular 怎么实现动态添加repeat标签

    <tr ng-repeat="item in data">
        {{item.name}}
    </tr>

动态添加上文的字符串,怎么才能让它生效,实现动态绑定。

大概代码如下

    var str = '<tr ng-repeat="item in data">' + 
            '{{item.name}}' +
        '</tr>';
    angular.element('tbody').html(str)
ringa_leeringa_lee2744 days ago499

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-05-15 16:58:15

    http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-15 16:58:15

    What needs to be done by operating dom to load angular tags
    Please use ng-if or ng-show to control it.
    If you want to operate DOM, please use directive reference: angular coding standards

    reply
    0
  • Cancelreply