javascript - How do you inject a factory function with Aurelia's DI container? -
i'd make third-party object on window
injectable can test functionality independent of third-party service. component i'm trying build simple wrapper around disqus embedded comments. factory use simple as
() => window.disqus
has been able or know if possible?
use registerinstance
string key this:
container.registerinstance('disqus', window.disqus);
then can inject disqus instance view models this:
import {inject} 'aurelia-framework'; @inject('disqus') export class foo { constructor(disqus) { this.disqus = disqus; } ... }
Comments
Post a Comment