There are two ways to define dependencies which you would like injected into your objects in Aurelia:
- Use the `inject` decorator
- Use the static `inject` member
Using the static inject member has the benefit of not needing to import `inject` from the aurelia-framework:
import {Todo} from './todo'; import {Factory} from 'aurelia-dependency-injection'; import {EventAggregator} from 'aurelia-event-aggregator'; export class App { static inject = [EventAggregator, Factory.of(Todo)]; constructor(aggregator, todoFactory) { this.bus = aggregator; this.completedTodos = 0; this.newTodoDesc = ''; this.todos = []; this.todoFactory = todoFactory; } }