Quantcast
Viewing all articles
Browse latest Browse all 4826

Explain action name in a template

@belgoros wrote:

I wonder what is the difference between the following actions definitions:

  1. When defined as <a {{action 'login'}}>Login</a>
  2. When defined as {{#link-to ‘index’ }}Home{{/link-to}}

Is is correct to say that when using with {{#link-to 'index' }} helper, I should always define a route with the same name as the String passed in to link_to helper ?

  1. Should actions be always declared in controllers only ?
  2. What does the below declaration (onLogin) mean (in app/components/main-navigation.js):
actions: {
    login() {
      // Closure actions are not yet available in Ember 1.12
      // eslint-disable-next-line ember/closure-actions
      this.sendAction('onLogin');
    },
  1. What does the onLogin='transitionToLoginRoute declaration mean (in app/templates/application.hbs):
{{main-navigation onLogin='transitionToLoginRoute'}}

There is no action onLogin defined anywhere. Is there any convention to explain this ? Thank you.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles