我在這裏有一些問題,我使用Angular2和Nativescript的本地JS的混合使用HTTP,因爲在此實現之前我遇到了Angular2 HTTP的問題,但是我對如何將來自http請求的JSON響應放到monthList變量中感到沮喪,因此可以在整個地方讀取它。請幫助,謝謝。Nativescript:如何將HTTP值存儲到公共變量
這裏是我的代碼:
public monthList = [];
constructor(location: Location, private page: Page, private router: Router, private testing: any) {
this.router = router;
this.testing = testing;
let http = require("http");
http.getJSON("link")
.then(function (r) {
// Argument (r) is JSON!
}, function (e) {
// Argument (e) is Error!
console.log(e);
});
}
大部分控制檯返回uncaught在諾言類型的錯誤...然後顯示只在android模擬器空白... –