如何使用JavaScript渲染控件标签输入angularjs?

时间:2018-11-12 10:29:58

标签: javascript angularjs laravel

创建时

  

CSS

 <link rel="stylesheet" href="{!! asset('css/input_tags/ng-tags-input.bootstrap.css') !!}">
    <link rel="stylesheet" href="{!! asset('css/input_tags/ng-tags-input.css') !!}">
  

js

<script type="text/javascript" src="{!! asset('js/angular.min.js') !!}"></script>
<script type="text/javascript" src="{!! asset('js/angular-route.min.js') !!}"></script>
<script id="jsTagput" type="text/javascript" src="{!! asset('js/input_tags/ng-tags-input.js') !!}"></script>
  

html

<tags-input ng-model = "tags" placeholder = "Add a tag keyword"></ tags-input>
  渲染时的

代码   enter image description here

正常显示。 但是使用javascript创建时无法渲染

  

js

var dv = document.createElement("div");
    dv.className = "form-group";
    dv.innerHTML = '<div class="input-group mb-3 ip-mb3">\n' +
        '                                    <input type="text" class="form-control" placeholder="Unit ID">\n' +
        '                                    <div class="input-group-append">\n' +
        '                                    <span class="input-group-text">\n' +
        '                                        <a class="linkdescription" onclick="removeObjectUnitId(this)">\n' +
        '                                            <i class="fa fa-minus" style="color: red" aria-hidden="true"></i>\n' +
        '                                        </a>\n' +
        '                                    </span>\n' +
        '                                    </div>\n' +
        '                                </div>\n' +
        '                                <tags-input ng-model="tags" placeholder="Add a tag keyword">\n' +
        '                                </tags-input>\n' +
        '\n' +
        '                                <tags-input ng-model="tags" placeholder="Add a tag label">\n' +
        '                                </tags-input>';

    document.getElementById("dvUnitId").appendChild(dv);
  

html

enter image description here

请帮助我!非常感谢你!

0 个答案:

没有答案