1

Lots of tutorials show how we can use ViewContainerRef to dynamically insert a component to implement widgets like a dialog pop-up. (eg. https://www.lucidchart.com/techblog/2016/07/19/building-angular-2-components-on-the-fly-a-dialog-box-example/)

I was wondering what are the benefits over just using an *ngIf ? I could just:

<my-dialog-component *ngIf="someFlagControlledByAService"></my-dialog-component>

which could save many lines of code

Thanks a lot!

Marlon Ou
  • 471
  • 1
  • 6
  • 19
  • check this [**answer**](http://stackoverflow.com/questions/42735858/ng2-bootstrap-show-hide-modal-as-child-component/42736058#42736058) – Aravind May 13 '17 at 04:27
  • 1
    That answer doesn't really answer my question... The answer provided can also be done in ngIf right? What are the benefits of using this answer's method? – Marlon Ou May 13 '17 at 15:29

0 Answers0