Ciprian
Ciprian

Reputation: 3226

Angular2 - Navigating to single item

How can I navigate to a single event from a list of events?

<md-card *ngFor="let event of events | async">
    <a href="" routerLinkActive="event/{{event.slug}}"><img class="event-img" src="http://lorempixel.com/30/30" />{{ event.name }}</a>
</md-card>

Upvotes: 0

Views: 77

Answers (1)

developer033
developer033

Reputation: 24894

As said in docs of RouterLinkActive:

The RouterLinkActive directive lets you add a CSS class to an element when the link's route becomes active.

To navigate, you should use RouterLink:

<a [routerLink]="['event', event.slug]"

or

<a routerLink="event/{{event.slug}}"

Upvotes: 1

Related Questions