从javascript构建HTML
我有一个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>
<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
。为什么要这样做?特别是在有棱角的地方?