1

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?

1

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the tip! Could you please explain why should this be avoided?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.