I would like to load a certain template based on a condition. The value of the condition is retrieved via an @Input(). How do I choose the value for the templateUrl key in the annotation based on this value?
-
1I suppose there's a similar question: stackoverflow.com/questions/36071097/…Zasypin N.V.– Zasypin N.V.2016-12-26 11:15:06 +00:00Commented Dec 26, 2016 at 11:15
Add a comment
|
1 Answer
You should avoid this and break it to 2 separated components. In that case, you can use ngSwitchCase and depending on value load the component you need for that case, or you can use the same component but add two html blocks with *ngIf and then you can show/hide whatever you need.
2 Comments
Karma
Thanks for the tip! Could you please explain why should this be avoided?
Igor Janković
Because, the point of the angular 2 is to separate all the things to the small components and avoid large components with the lot of if/else logic.