Skip to content
Advertisement

Combine linkTo and action helpers in Ember.js

I need to combine linkTo and action helpers in Ember.js. My code is:

JavaScript

But I would like to make this something like this:

JavaScript

And also:

JavaScript

To:

JavaScript

How can I achieve this?

Solution

Check my answer for Ember 2.0 compatible, OK for SEO solution.

Advertisement

Answer

Ember Link Action addon

This is OK for SEO solution!

Install addon

JavaScript

Usage

You can pass closure action as invokeAction param to {{link-to}} component:

JavaScript

To pass parameters to action you can use:

JavaScript

Compatibility

Automated test suite confirms that addon works with 1.13 up to latest Ember 3 releases.

It works with a release, beta and canary versions of Ember.

Addon GitHub repository. Contributions are welcome.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement