Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend an ember-cli addon?

In my ember-cli app i have installed an addon called 'ember-cli-selectize'. Looking at the directory structure i can see that its files are located at /node_modules/ember-cli-selectize'. Now i want to create a custom component that extends this addon. How do i import/require it? I've tried these and none seems to work:

var EmberSelectize = require('/ember-cli-selectize/app/components/ember-selectize');

import EmberSelectize from 'components/ember-selectize';

import EmberSelectize from 'node_modules/ember-cli-selectize/addon/components/ember-selectize';

import EmberSelectize from 'ember-cli-selectize/addon/components/ember-selectize';

i always get this 'Could not find module' error no matter what. I need to somehow import/require it to do something like

import EmberSelectize from 'wherever/it/is';
export default EmberSelectize.extend({
  //my own customizations
})
like image 628
Saarang Avatar asked Feb 22 '15 04:02

Saarang


1 Answers

You were close with:

import EmberSelectize from 'components/ember-selectize';

Addons namespace themselves - in this case, ember-cli-selectize. So, just add the namespace to your import:

import EmberSelectizeComponent from 'ember-cli-selectize/components/ember-selectize';

then you can extend:

export default EmberSelectizeComponent.extend({ });
like image 95
Sam Avatar answered Oct 08 '22 21:10

Sam