Extend Ember component without changing template

Sami picture Sami · Aug 21, 2015 · Viewed 7.2k times · Source

I have an Ember application and want to extend a component to override some functionality, but don't want to change or duplicate the template.

However, if I just import and extend the component, nothing is rendered.

How can I make my extended component render using the template that I extended from?

Answer

Sami picture Sami · Aug 22, 2015

Thanks to the question answered here How can I share a template between two components using Ember CLI? I was able to add a layoutName to the child component pointing to the parent template and solved my problem. My code finally looks like this:

import Ember from 'ember';
import ExtendFromComponent from './extend-from';

export default ExtendFromComponent.extend({
  layoutName: 'components/extend-from'
});