user3117848
user3117848

Reputation: 11

Naming an Ember.Component subclass

I have a template with an id of components/preview/image. I want to create a subclass of Ember.Component that corresponds to this template.

If the template had an id of components/image, I could create a subclass of Ember.Component called ImageComponent.

The preview/ nesting inside of components/ is throwing a wrench into my plans. Preferably, I would like to name the component PreviewImageComponent.

Upvotes: 1

Views: 162

Answers (1)

Steve H.
Steve H.

Reputation: 6947

The naming is a convention- you must use a dash and not underscore in the name. Create your template with the id components/preview-image and use the following template tag:

{{preview-image url=foo}}

and then create your component like this:

App.PreviewImageComponent = Ember.Component.extend({
    // implementation here
});

EDIT: Just to be really clear: a dash somewhere in the name is required

Upvotes: 1

Related Questions