Я играю с обучающим героем из https://github.com/angular-examples/toh-6/tree/master
hero_service.dart
@Injectable()
class HeroService {
static final _headers = {'Content-Type': 'application/json'};
static const _heroesUrl = 'api/heroes'; // URL to web API
final Client _http;
HeroService(this._http);
Future<List<Hero>> getAll() async {
try {
final response = await _http.get(_heroesUrl);
final heroes = (_extractData(response) as List)
.map((json) => new Hero.fromJson(json))
.toList();
return heroes;
} catch (e) {
throw _handleError(e);
}
}...
Я вставляю browserclient в main.dart
@GenerateInjector([
routerProvidersHash, // You can use routerProviders in production
//const ClassProvider(Client, useClass: InMemoryDataService),
// Using a real back end?
// Import 'package:http/browser_client.dart' and change the above to:
const ClassProvider(Client, useClass: BrowserClient),
])
final InjectorFactory injector = self.injector$Injector;
void main() {
runApp(ng.AppComponentNgFactory, createInjector: injector);
}
При звонке_http.get(_heroesUrl)
для внедренного экземпляра BrowserClient
я получаю следующее исключение.SDK версии 2.0.0-dev.55.0
EXCEPTION: Exception: Server error; cause: Type 'NativeJavaScriptObject' is not a subtype of expected type 'HttpRequest'.
STACKTRACE:
packages/$sdk/dev_compiler/amd/dart_sdk.js 4823:29 throw
packages/angular_tour_of_heroes/src/hero_service.ddc.js 32:21 getAll
packages/$sdk/dev_compiler/amd/dart_sdk.js 23502:38 onError
packages/stack_trace/stack_trace.ddc.js 142:98 <fn>.dart.fn
packages/stack_trace/stack_trace.ddc.js 188:16 [_run]
packages/stack_trace/stack_trace.ddc.js 142:80 arg
packages/angular/src/core/zone/ng_zone.ddc.js 115:18 arg