O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing a component's element class

Since components are views, their element's class can be specified statically or dynamically using the classNames and classNameBindings array properties on the component's class. For example, the post-input component defines a static class as:

App.PostInputComponent = Ember.Component.extend({
  classNames: ['post-input'],
});

This results in the component being rendered as:

<button class='post-input'>add</button>

In the sample application, we mentioned that users are able to rate uploaded photos. The user-post component uses the post-rating component that serves as the rating widget:

{{post-rating content=post}}

Each of the stars in the latter part is also a component (post-rating-item) and is listed horizontally ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required