dimanche 3 juin 2018

Conditional selection of components from different module in angular

I have two modules in angular.

1. ModuleX
    It has a component X, with selector='app-x'
2. ModuleY
    It has a component Y, with selector='app-y'

Now In some page in some other module we have to write like this:

<div *ngIf="booleanCondition"; else secondOption>
    <app-x></app-x>
</div>

<ng-template #secondPage>
    <app-y></app-y>
</ng-template>

I have declared and exported component X and component Y from their respective modules and also imported these modules in module in which our current page exists.

Browser is giving some StaticInjectorError. Why does this happen, while if I use these tags in their respective module's page it works.




Aucun commentaire:

Enregistrer un commentaire