williamsandonz
williamsandonz

Reputation: 16420

How to create a re-usable routerLink directive in Angular2

I have a common route throughout my application, it is referenced like so:

<a [routerLink]="['/Project', {id: project.id, title: project.urlTitle}]" href="#">
  {{project.title}}
</a>

How can I make this logic re-usable using a directive or similar?

I.E Ideally I'd like to do something like:

<a [project-link]="project"></a>

Upvotes: 3

Views: 162

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657218

Just create a component that contains the routerLink.

Upvotes: 2

Related Questions