Nicholas Tuck
Nicholas Tuck

Reputation: 551

Angular Dart custom injection failing in dart2js

I have a podo class CarStorage for angular to inject.

class CarStorage {
  int _carIdCounter = 0;
  ...

I wire it in using type:

module
    ..type(CarForm)
    ..type(CarItemsList)
    ..type(CarStorage)
    ;

It works in dartium but fails to load in dart2js. I get the following error:

Illegal argument(s): No type factory provided for CarStorage! (resolving GarageAppController -> CarStorage)

Upvotes: 1

Views: 271

Answers (1)

Nicholas Tuck
Nicholas Tuck

Reputation: 551

I discovered through some bug reports and guess work you need to add the DI Injectable annotation:

import "package:angular/angular.dart";

@Injectable()
class CarStorage {
  ...

edit: Fixed the import.
Do NOT use import 'package:di/annotations.dart'; this causes errors

Upvotes: 2

Related Questions