Also update dart_to_js_script_rewriter dependency to ^1.0.1, and change most angular2.dart imports to be core.dart instead. The pipes example broke without the angular2.dart import, so I let it be. The server-communication sample has never worked for me, so I changed it but might have broken it further. closes #1007
26 lines
598 B
Dart
26 lines
598 B
Dart
// #docregion
|
|
import 'dart:async';
|
|
|
|
import 'package:angular2/core.dart';
|
|
import 'package:jsonpadding/jsonpadding.dart';
|
|
|
|
@Injectable()
|
|
class WikipediaService {
|
|
Future<List<String>> search(String term) async {
|
|
// #docregion call-jsonp
|
|
Uri uri = new Uri(
|
|
scheme: 'http',
|
|
host: 'en.wikipedia.org',
|
|
path: 'w/api.php',
|
|
queryParameters: {
|
|
'search': term,
|
|
'action': 'opensearch',
|
|
'format': 'json'
|
|
});
|
|
// TODO: Error handling
|
|
List result = await jsonp(uri);
|
|
return result[1];
|
|
// #enddocregion call-jsonp
|
|
}
|
|
}
|