1

I have Ember component that has some functions defined e.g.:

export default Ember.Component.extend({

  _someFunction: function(){}

});

Now if I import this component in some other component:

import FirstComponent from 'somePath...';

Can I and how call _someFunction from FirstComponent? I tried this FirstComponent._someFunction(), but I get errors (is not a function).

I can define this function outside the Ember component and export this function alone but is there some other way?

user3921420
  • 463
  • 1
  • 5
  • 10

1 Answers1

1

Since Ember.Component is a class and you have instance method _someFunction in it. You'll have to create it's instance first to access that method. Hence you should try

const instance = FirstComponent.create();
instance._someFunction();
code-jaff
  • 9,230
  • 4
  • 35
  • 56