AngularM AngularM - 6 months ago 13
AngularJS Question

In angular2 routerLink on my view isnt working. How do I do an routerLink on my view and how do I import this?

In angular2 routerLink on my view isnt working. How do I do an routerLink on my view and how do I import this?

I'm using the new @angular/router.

This is my code:

import {Component, View} from '@angular/core';

import {Router, Routes, ROUTER_DIRECTIVES} from '@angular/router';

import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgIf} from '@angular/common';

@Component({
moduleId: module.id,
selector: 'ForgotPassword',
templateUrl: 'forgotpassword.html',
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, NgIf, ROUTER_DIRECTIVES]
})

export class ForgotPassword{}


This is my html

<a class="link" [routerLink]="['Login']">Login</a>

Answer

try this

<a class="link" [routerLink]="['/login']">Login</a>