Jeff G
Jeff G

Reputation: 2175

Having trouble injecting Aurelia's EventAggregator into a particular class

I use the EventAggregator in several places in my app and everything works fine. However I’m having trouble injecting it into one of my classes. When the class constructor is called, the EventAggregator argument is undefined.

import {EventAggregator} from 'aurelia-event-aggregator';
import {inject} from 'aurelia-framework';

@inject(EventAggregator)
export class Test {
    constructor(eventAggregator) {
        debugger;
        this.eventAggregator = eventAggregator;
    }
}

When stopping at the debugger; line, the constructor’s eventAggregator argument is undefined.

This looks just like what I have done to use EventAggregator in many other classes, so what could be the issue?

Upvotes: 0

Views: 327

Answers (1)

Jeremy Danyow
Jeremy Danyow

Reputation: 26406

I think this has to do with forks (multiple version of the same package installed).

  1. To clean this up, open your config.js file and delete everything inside the map: { node. For example- all this.
  2. Then execute jspm install.
  3. Then check for forks again. jspm inspect --forks
  4. If you still have forks, execute jspm install aurelia-_______ for each aurelia item listed in your package.json

In fact- you may want to skip right to step 4- this will ensure you get the latest, which is now 1.0.0 (RTM) version of aurelia.

Upvotes: 1

Related Questions