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

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

Can someone please illustrate the difference between using and elements?

I could not find document

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 01:03

    ng-template is used for the structural directive like ng-if, ng-for and ng-switch. If you use it without the structural directive, nothing happens and it will render.

    ng-container is used when you don't have a suitable wrapper or parent container. In most cases, we are using div or span as a container but in such cases when we want to use multiple structural directives. But we can't use more than one structural directive on an element, in that case, ng-container can be used as a container

提交回复
热议问题