Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
200 views
in Technique[技术] by (71.8m points)

html - Using table formatting inside innerHTML

I have an app that changes the text in the Legend window based on what the user selects. That seems to work fine for text of any size. But 2 of the legends include a small table. That table is showing up without any formatting. The code is rather simple.

<div style= "position: fixed; Top: 55px; right: 20px;" >
  <div class="legend-container">
    <div class="title">{{legendTitle}}</div>
     <div #graphOverviewComponentRef id="legend-overview-component">
       <p [innerHTML]="queryInfo"></p> 
     </div>
    </div> 
  </div>
</div>  

queryInfo contains a table. This is the cut down version.

<!DOCTYPE html><html><head><style>table {font-family: arial, sans-serif; border-collapse: collapse; width: 150;}td, th { border: 1px solid #dddddd;text-align: left; padding: 8px; font-size: .8em;}tr:nth-child(even) {background-color: #8C8CD9;}</style></head><body><table><tr><th>Var</th><th>Value</th><th>Var</th><th>Value</th></tr><tr><td>Bus User</td><td>Logon </td><td>interest</td><td>Violations</td></tr><tr><td>Query</td><td>undefined </td><td>Organization</td><td>all</td></tr><tr><td>Vendor</td><td>all </td><td>Source</td><td>SonarCube</td></tr><tr><td>Status</td><td>Login </td><td></td><td></td></tr></table></body></html>

When I paste that into the stream inline, it shows up perfectly (cut down a bit)

<div #graphOverviewComponentRef id="legend-overview-component">

  <!DOCTYPE html><html><head><style>table {font-family: arial, sans-serif; ..............
</div>

So my HTML does not seem to be the problem. So why is innerHTML not formatting the table ?

Thanks

question from:https://stackoverflow.com/questions/65939332/using-table-formatting-inside-innerhtml

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...