Recently, I have started playing with angular 2. It\'s awesome so far. So, i have started a demo personal project for the sake of learning using angular-cli
. <
I totally chose another way for this method.
app.component.ts
import { Router } from '@angular/router';
export class AppComponent {
constructor(
private router: Router,
) {}
routerComment() {
this.router.navigateByUrl('/marketing/social/comment');
}
}
app.component.html
<button (click)="routerComment()">Router Link </button>
You need to add RouterMoudle
into imports
sections of the module containing the Header
component
In the current component's module import RouterModule.
Like:-
import {RouterModule} from '@angular/router';
@NgModule({
declarations:[YourComponents],
imports:[RouterModule]
...
It helped me.