Reputation: 31
I have an app that I've primarily built in AngularDart v0.12 that was building into and running in JS just fine, but after upgrading to AngularDart v1.0 and accounting for the breaking changes, it fails to run in JS now after building to it without a problem. When attempting to run in Chrome the console gives the following error:
Uncaught Type "QueryService" not found in generated typeFactory maps
The following is my pubspec.yaml config:
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
The following is my module class:
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);
}
}
The following is the QueryService class:
@Injectable()
class QueryService{
Http _http;
Scope _scope;
QueryService(Http this._http, Scope this._scope){
someFunction();
}
}
Just to reiterate, this application is working fine when run using the DartVM, but doesn't seem to want to inject the QueryService when built into JS.
Also, I'm aware this may be very similar to this question, but the solution doesn't appear to have any effect in my case, and the AngularDart version is newer.
Upvotes: 0
Views: 121
Reputation: 31
Apparently I was importing my app's library directly via a relative path in my main.dart file instead of importing it as a package. This caused a duplicate declaration of the library which must have given the transformer some issues. I basically just had to change my import on my main.dart file from
import '../library/src/app.dart';
to
import 'package:myPackage/app.dart'
Upvotes: 1
Reputation: 144
The @Injectable annotation should trigger the generation of the factory.
If it's not may be you are not running the angular transformer ?
You pubspec should list this transformer, ie:
name: myApp
dependencies:
angular: ">=1.0.0 <2.0.0"
transformers:
- angular
Upvotes: 1