Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

How to use positionalParams with angle bracket invocation

$
0
0

@ef4 wrote:

A component with positionalParams always also has named versions of its parameters. For example, the liquid-if component from liquid-fire has this in its Javascript file:

positionalParams: ['predicate']

That means it accepts one positional parameter, which will be named predicate. So these are equivalent:

{{#liquid-if isActive}}
{{/liquid-if}}

<LiquidIf @predicate={{isActive}} >
</LiquidIf>

There is a second way to use positionalParams, which is to gather a variable number of them into an array. That is how link-to works:

// notice that the right-hand value here is a single 
// name, not an array like in the previous example
positionalParams: 'params'

So we can pass the @params=, but unfortunately the value we pass needs to be an array, so you may want something like ember-array-helper:

{{link-to "posts" 1}}
<LinkTo @params={{array "posts" 1}} />

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles