JayNewbie
JayNewbie

Reputation: 25

How do I open another component using Angular without displaying the first one?

I am new to the Angular world and hope that this question makes sense:

Say I have a section under app.component.html:

<section id="zoo">Zoo</section>

Now I create another component (zoo) using the following command:

ng g c zoo

This will create 4 new files for zoo.

What I want now is to click on the section (zoo) that will redirect me to the created zoo-page and ONLY display the content for that page.

How can I do that?

Upvotes: 1

Views: 1053

Answers (1)

Juaasca
Juaasca

Reputation: 26

First create a new route like this { path: 'zoo', component: ZooComponent }. Then change your html for <section id="zoo" routerLink="/zoo">Zoo</section>

Upvotes: 1

Related Questions