我在AngularDart v0.14.0 pub服务器上测试我的应用程序,但它有错误
Exception: Uncaught Error: Type 'CurrencyService' not found in generated typeFactory maps. Is the type's constructor injectable and annotated for injection?
Stack Trace:
#0 GeneratedTypeFactories.parameterKeysFor (package:di/src/reflector_static.dart:26:5)
#1 Binding.bind (package:di/src/module.dart:61:49)
#2 Module.bindByKey (package:di/src/module.dart:136:17)
#3 Module.bind (package:di/src/module.dart:124:14)
#4 CERPModule.CERPModule (http://localhost:8080/index.dart:71:9)
#5 main.<anonymous closure> (http://localhost:8080/index.dart:59:201)
#6 _RootZone.runUnary (dart:async/zone.dart:1082)
#7 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
#8 _Future._propagateToListeners (dart:async/future_impl.dart:571)
#9 _Future._completeWithValue (dart:async/future_impl.dart:331)
#10 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
#11 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#12 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#13 _handleMutation (dart:html:39006)
在localhost:3030中运行时,不会发生此错误。
这是我的模块
class CERPModule extends Module {
...
bind(CurrencyService);
...
}
这是我的CurrencyService
library cerp_currency_service;
import 'dart:async';
import 'dart:convert';
import 'package:angular/angular.dart';
class CurrencyService {
Http _http;
CurrencyService (Http this._http);
...
}
答案 0 :(得分:1)
据我所知,您需要将@Injectable
注释添加到CurrencyService
课程中。
@Injectable()
class CurrencyService {