在角度2中的* ng-for循环中添加html

时间:2015-12-10 10:18:11

标签: javascript angular

我想从角度为2的for循环中的变量中添加html代码:

<ul>
   <li *ng-for="#c of myHtmlItems">
      {{c.myHtml}}
   </li> 
</ul>

html仅作为字符串添加

3 个答案:

答案 0 :(得分:4)

更新到angular2.0.0

#
  1. * ng-for已替换为* ngFor
  2. let已替换为[innerHTML]='c.myHtml'
  3. inner-html with innerHTML (最好使用像inner-html="{{c.myHtml}}而不是Option Explicit Sub main() Dim bottom As Long, top As Long, lastColumn As Long, iCol As Long bottom = 275 top = 1600 lastColumn = 20 '<-- specify last column index or get it through some function For iCol = 4 To lastColumn '<--| loop through columns from 4 to lastColumn With Cells(5, iCol).Resize(, 3) '<--| reference three contiguous cells in the same row from current one .Select Select Case True Case WorksheetFunction.Min(.value) < bottom '<--| there's one value too small MsgBox "small!" ' do something Case WorksheetFunction.Max(.value) > top '<--| there's one value too big MsgBox "big!" ' do something Case Else '<--| all value in range MsgBox "ok!" ' do something End Select End With Next iCol End Sub
  4. 这样的属性绑定

答案 1 :(得分:2)

你可以这样做:

<ul>
    <li *ng-for="#c of myHtmlItems" inner-html="{{c.myHtml}}></li>
</ul>

答案 2 :(得分:-2)

而不是ng-for,尝试使用ng-repeat。因为大多数ng-repeat在非常不同的方面很有用

      <ul>
         <li ng-repeat="element in myHtmlItems">
            {{element}}
         </li> 
      </ul>