AngularDart Dependency Injection
Using [ClassProvider(MyRepository)]
in your app_component
tell the compiler to override what you have set in your main.dart
file.
Try this:
@Component( selector: 'app-component', templateUrl: 'app_component.html',)@Injectable()class AppComponent { final MyRepository _myRepository; AppComponent(this._myRepository);}
EDIT:
Your main.dart file is incorrect, you have to reference the injector from the main.template.dart :
import 'package:angular/angular.dart';import 'package:angular_dart/app_component.dart';import 'package:angular_dart/app_component.template.dart' as ng;import 'main.template.dart' as self;@GenerateInjector([ ClassProvider(MyRepository, useClass: ng.MyRepositoryImpl),])final InjectorFactory injector = self.injector$Injector;void main() { runApp(ng.AppComponentNgFactory, createInjector: injector);}