Created
May 26, 2015 05:39
-
-
Save lacolaco/b421852eaa8b586b2c34 to your computer and use it in GitHub Desktop.
Mapにデコードしてjsonパイプを噛ませる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library component.ajax; | |
import "package:angular2/angular2.dart"; | |
import "dart:html"; | |
import 'dart:convert'; | |
@Component(selector: "ajax-data") | |
@View( | |
template: "<p>{{ data | json }}</p><button (click)='getData()'>Get data.json</button>") | |
class AjaxComponent { | |
Map<String, dynamic> data; | |
AjaxComponent() { | |
data = {}; | |
} | |
getData() async { | |
this.data = await HttpRequest.request("./data/data.json").then((req) { | |
return JSON.decode(req.responseText); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment