Archer
Archer

Reputation: 1162

How to pass parameters/attributes to a component in EmberJs when using "as" operator

I have a structure to invoke my component in this way, in a .hbs file

{{#myComponent as |section|}}
  {{#if (eq section "section1")}}

    this is the content for the first section <br>  

  {{else if (eq section "section2")}}

    Some content for section two <br>
    More content for second section <br>

  {{/if}}
{{/myComponent}}

I want to be able to pass some parameters along, like this

{{#myComponent as |section| param1="xyz" param2=true}}

It is resulting in a parse error while build.

How can i still pass parameters to be accessed by the component in this scenario?

Thanks in advance!!

Upvotes: 0

Views: 66

Answers (1)

Archer
Archer

Reputation: 1162

Figured that the entire component object has to be used, and then the "as" key word follows. Like this

{{#myComponent  param1="xyz" param2=true as |section|}}

Upvotes: 2

Related Questions