mardi 8 décembre 2015

Ember script inject and access in computed property

I have a script (Recurly.js API) that I inject using the ember-inject-script and then initialize it.

export function initialize(container, application) {
  var url = "http://ift.tt/1vxQnH9";
  injectScript(url).then(function() {
    recurly.configure(config.recurly.publicKey);
  });
}

export default {
  name: 'recurly',
  initialize: initialize
};

And I have access to it using the recurly variable but I seem to be having issues getting access to this in a computed property. Such as

taxCalc: Ember.computed('plan', function() {
    console.log(recurly);
}),

I've also tried

taxCalc: Ember.computed('plan', 'recurly', function() {
    var recurly = this.get('recurly');
    console.log(recurly);
}),

But doesn't seem like anything is working for me. I always get recurly is not defined. This seems to work fine however if called from an action. Thanks in advance




Aucun commentaire:

Enregistrer un commentaire