ng2 - Difference between ng-container and ng-template tags

前端 未结 7 970
温柔的废话
温柔的废话 2020-12-01 00:15

Can someone please illustrate the difference between using and elements?

I could not find document

7条回答
  •  -上瘾入骨i
    2020-12-01 01:04

    I like as a way to separate "logic" from "markup" as much as possible in the Angular .component.html files.

    (partial) example to render rows of an html table:

            
              
                
                {{ product.productName }}
                {{ product.productCode }}
                {{ product.releaseDate }}
                {{ product.price }}
                {{ product.starRating }}
              
            
    

    That way, if I want to change from an HTML

    to something else, such as a bunch of
    with flexbox styling, I don't need to "carve out" the looping logic (or risk losing it completely) from inside the
    . It also keeps the looping (ngFor) logic from being partially obscured by the normal html.

    提交回复
    热议问题