mardi 26 janvier 2016

How do I make dynamic classNames in an ember 2.0 component?

For example: Ember components allow you to add a classNames array and those classes will be added to the main div of the component. say we have this component called new-div export default Ember.Component.extend({ classNames: ['container'] });

then if you inspect this component when rendered you will see: <div id="ember595" class="ember-view container"> ... </div>

this is fine but my issue is what if i want to use this component as a fluid container sometimes and sometimes I might want to make it a jumbotron etc...

Is there a way to do this in the html and have the component.js apply it correctly?

like: {{new-div extra-classes='class1,class2'}}

then in the component.js:export default Ember.Component.extend({ classNames: [this.get('class-names')] });




Aucun commentaire:

Enregistrer un commentaire