Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从javascript构建HTML_Javascript_Html_Angularjs - Fatal编程技术网

从javascript构建HTML

从javascript构建HTML,javascript,html,angularjs,Javascript,Html,Angularjs,我有一个HTML表,它是以以下方式构建的:- <table class="table table-striped table-hover"> <thead> <tr> <th>Party</th> <th>Name</th> <th>Chamber</th> <th>District</th> <th>

我有一个HTML表,它是以以下方式构建的:-

<table class="table table-striped table-hover"> 
    <thead> 
        <tr>
            <th>Party</th> <th>Name</th> <th>Chamber</th> <th>District</th> <th>State</th> 
        </tr>
    </thead> 
    <tbody> 
        <tr dir-paginate="user in users|filter:search|itemsPerPage:10"> 
            <td> <img src="{{user.party_name}}" style="max-height: 10%;max-width: 10%;"/> </td> 
            <td>{{user.fullname}}</td> 
            <td > <img src="{{user.chamber_type}}" style="max-height: 8%;max-width: 7%;"/>{{user.chamber_name}} </td> 
            <td>{{user.district_name}}</td> 
            <td>{{user.state_name}}</td> 
            <td> <button type="button" class="btn btn-primary">View Details</button></td> 
        </tr> 
    </tbody> 
</table> 

党名商会区州
{{user.fullname}
{{user.chamber_name}
{{user.district\u name}
{{user.state_name}
查看详细信息
可以从javascript创建这个表吗?在HTML中,我只创建了一个div,并将从javascript创建的表追加到这个div中。我尝试将上述内容放入一个javascript变量并进行追加,但没有成功。有没有办法做到这一点??我想这可能是因为角度变量。如果我错了,请纠正我。我对此很陌生。

在AngularJS中使用
并将html代码保存在
$scope.html var

为此,您需要在AngularJS中包含

,使用
并将html代码保存在
$scope.html var


为此,您需要包括

查看
$compile
。这当然是可能的,例如查看
文档.createElement
文档.appendChild
。为什么要这样做?特别是在angular?查看
$compile
。这绝对是可能的,例如查看
document.createElement
document.appendChild
。为什么要这样做?特别是在有棱角的地方?