Search code examples
htmlangularangular2-routingfilepathrouterlink

How do I link internal files in Angular?


I'm trying to link my login page from the navbar. This is what I have for navbar:

<div class="navbar-container">
  <ul id="slide-out" class="side-nav center-align">
    <li>
      <div class="user-view center-align">
        <a><i class="medium material-icons close-button">close</i></a>
      </div>
    <li><a routerLink="../login">Login</a></li>
  </ul>
  <a href="#" data-activates="slide-out" class="button-collapse"><i class="small material-icons {{updateMe()}}">filter_list</i></a>
</div>

And this is my file structure:

file structure

However, it just doesn't link to the component. The error I get is:

core.js:1542 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'login'

Am I using relative paths wrong? How can I fix this? Thank you!


Solution

  • At first, you need to set all paths in routes array which is present in app.module.ts. Please check if you've developed it perfectly.