positionalParamspublicstatic
Enables components to take a list of parameters as arguments.
For example, a component that takes two parameters with the names name and age:
let MyComponent = Ember.Component.extend;
MyComponent.reopenClass({
positionalParams: ['name', 'age']
});
It can then be invoked like this:
{{my-component "John" 38}}
The parameters can be referred to just like named parameters:
Name: {{attrs.name}}, Age: {{attrs.age}}.
Using a string instead of an array allows for an arbitrary number of parameters:
let MyComponent = Ember.Component.extend;
MyComponent.reopenClass({
positionalParams: 'names'
});
It can then be invoked like this:
{{my-component "John" "Michael" "Scott"}}
The parameters can then be referred to by enumerating over the list:
{{#each attrs.names as |name|}}{{name}}{{/each}}
Please login to continue.