How to toggle between links in ember.js?

Member

by lottie , in category: Javascript , 9 months ago

How to toggle between links in ember.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cali_green , 9 months ago

@lottie 

You can toggle between links in Ember.js by using the {{#link-to}} helper in your templates.


For example, if you have two links in your template, you can use a conditional statement to toggle between them based on a property in your component or controller.

1
2
3
4
5
{{#if isLink1Active}}
  {{#link-to 'route1'}}Link 1{{/link-to}}
{{else}}
  {{#link-to 'route2'}}Link 2{{/link-to}}
{{/if}}


In this example, isLink1Active is a property in your component or controller that determines which link should be displayed. When isLink1Active is true, Link 1 will be displayed and when it is false, Link 2 will be displayed.


You can then update the isLink1Active property based on a user action or some other event in your Ember application to toggle between the links.

Related Threads:

How to toggle a circle on a canvas?
How to toggle between sources in grafana?
How to toggle a boolean value database field in laravel?
How to toggle pause/play audio with button click in pure javascript?
How to hide links in discord.js?
How to update symbolic links in git?