I am new to Angular 4 (and html as well) . I have ac# datatable object and I want to present it in an Angular application. So I turned this datatable to an HTML string such as :
<table class="table table - striped">
<tr><td>Name</td><td>BI</td><td>Run Time</td><td>Missing</td><td>Stale</td><td>Jump</td></tr>
<tr><td>something</td><td>223</td><td>4/10/2018 7:05:07 AM</td><td>0</td><td>1</td><td>0</td></tr>
</table>
and now I try to understand how to dynamically integrate this into my HTML file. What kind of binding should I use?
in your component's HTML add a div
as:
<div [innerHTML]="tableHTML"></div>
In component declare a variable and update this value whenever you get updated HTML string of table. It can be done as:
tableHTML: any;
onAfterViewInit(){
tableHTML = <updated HTML string> // tableHTML should be updated whenever you are getting data from back-end.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.