AngularDart v0.14.0 Error: Type 'xxx' not found in generated typeFactory maps when run pub server

假装没事ソ 提交于 2019-12-22 13:56:35

问题


I test my app on AngularDart v0.14.0 pub server but it has error

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)

When run in localhost:3030 this error don't occur.

Here is my Module

class CERPModule extends Module {
...
    bind(CurrencyService);
...
}

Here is my CurrencyService

library cerp_currency_service;

import 'dart:async';
import 'dart:convert';
import 'package:angular/angular.dart';


class CurrencyService {
  Http _http;
  CurrencyService (Http this._http);
...
}

回答1:


As far as I know you need to add the @Injectable annotation to your CurrencyService class.

@Injectable()
class CurrencyService {


来源:https://stackoverflow.com/questions/25575880/angulardart-v0-14-0-error-type-xxx-not-found-in-generated-typefactory-maps-wh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!