我有一个我主要在 AngularDart v0.12 中构建的应用程序,它在 JS 中构建并运行得很好,但是在升级到 AngularDart v1.0 并考虑到重大变化之后,它在构建后无法在 JS 中运行没有问题。尝试在 Chrome 中运行时,控制台会出现以下错误:
Uncaught Type "QueryService" not found in generated typeFactory maps
以下是我的 pubspec.yaml 配置:
name: ###
author: ###
description: ###
homepage: ###
transformers:
- angular:
dart_sdk: "C:/dart/dart-sdk"
suppressWarnings: false
- $dart2js:
suppressWarnings: false
minify: false
checked: true
dependencies:
angular: any
angular_dart_ui_bootstrap: any
bootjack: any
browser: any
chrome: any
di: any
dquery: any
google_oauth2_client: any
http_server: any
inject: any
js: any
logging: any
mock: any
mongo_dart: any
route: any
shadow_dom: any
shelf: any
shelf_route: any
shelf_web_socket: any
sqljocky: any
unittest: any
以下是我的模块类:
class AppModule extends Module{
AppModule(){
/*
* Services, Routers, and Controller
*/
bind(QueryService);
bind(RoutingService);
bind(RouteInitializerFn, toValue: initRoutes);
bind(NgRoutingUsePushState, toValue: new NgRoutingUsePushState.value(false));
/*
* Components
*/
bind(Login);
bind(Dashboard);
bind(SideNav);
}
}
以下是 QueryService 类:
@Injectable()
class QueryService{
Http _http;
Scope _scope;
QueryService(Http this._http, Scope this._scope){
someFunction();
}
}
重申一下,这个应用程序在使用 DartVM 运行时运行良好,但似乎不想在内置到 JS 时注入(inject) QueryService。
另外,我知道这可能与 this 非常相似。问题,但在我的情况下,该解决方案似乎没有任何效果,并且 AngularDart 版本更新。
最佳答案
@Injectable 注释应该触发工厂的生成。
如果不是,可能是您没有运行角度变压器?
你 pubspec 应该列出这个转换器,即:
name: myApp
dependencies:
angular: ">=1.0.0 <2.0.0"
transformers:
- angular
关于dart - AngularDart v1.0 Uncaught Type "[type]"not found in generated typeFactory maps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26428455/