-
-
Notifications
You must be signed in to change notification settings - Fork 405
Closed
Labels
T-frameworkRFCs that impact the ember.js libraryRFCs that impact the ember.js library
Description
It's possible to use the {{component}} helper in templates to specify a dynamic component name. This allows all kinds of polymorphic approaches to rendering data, which is awesome. However, as of now, it is not easily possible to bind a different set of arguments to dynamic components, which means that your components need to have the exact same API.
It's debatable whether or not this is a good idea, but if there was an equivalent to the component helper in JS, we would be able to construct a component with a different set of arguments.
The goal is to be able to do something like this:
{{#each this.items as |item|}}
{{component item.component}}
{{/each}}// app/controllers/index.js
export default Controller.extend({
items: computed('model', () => {
return this.model.map(item => {
let component;
if (item.type === 'foo') {
component = createComponent('special-component', { arg1: item.name, arg2: item.type });
} else {
component = createComponent('default-component', { otherArg: item.name });
}
return Object.assign(item, { component });
});
});
});This lets us use separate components based on item.type, but allows for flexibility in their API.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-frameworkRFCs that impact the ember.js libraryRFCs that impact the ember.js library