0

I am creating a CRUD application. I would like to know how do I break router-link when I click the view-student button.

Furthermore, it is possible to show the title only on the first page, so once you press the view-student button to delete the title too?

Thank you all from the heart

div class="container p-3 my-3 bg-primary text-white">
<h1>Welcome, click on the button below to see all students!</h1>
</div>

<div  class="container-fluid">  
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  
    <ul class="navbar-nav">  
      <li class="nav-item ">  
        <a routerLink="view-student" class="nav-link" class="btn btn-primary active" role="button" >View Student</a>  
      </li>   
    </ul>  
  </nav>     
    <router-outlet></router-outlet>  
</div>  

image

a_l_e_x
  • 408
  • 1
  • 6
  • 20
  • 1
    Can you try to explain further what you want to achieve? Specifically, what you mean by "stop" or "break" router link. – Clashsoft Jun 19 '21 at 11:40
  • Does the following question help? https://stackoverflow.com/questions/36753819/conditionally-add-routerlink-or-other-attribute-directives-to-an-element-in-angu – misha130 Jun 19 '21 at 11:52
  • @Clashsoft when I click on the view customer button I don't want the view-customer link to appear again – a_l_e_x Jun 19 '21 at 13:50
  • @misha130 that's not exactly what I want. – a_l_e_x Jun 19 '21 at 13:52
  • I put the image to understand what I am looking for – a_l_e_x Jun 19 '21 at 13:58
  • So you want to hide the link/button/anchor tag alltogether? You could use `routerLinkActive="d-none"` - this conditionally applies the `d-none` CSS class if the routerLink is currently active. `d-none` means `display: none;` in Bootstrap. – Clashsoft Jun 19 '21 at 14:03
  • Keep in mind though, that this is usually not done in navbars, because it is confusing UX. – Clashsoft Jun 19 '21 at 14:03

0 Answers0