我正在学习js提取。我试图从响应中获取temp的值,并在我的component.js中显示该值]
```
myApp.component('weatherComponent', {
template:"<p>Weather: {{vm.weather}}</p>",
controllerAs: 'vm',
controller: function WeatherController($scope,$element, $attrs) {
vm = this;
var apikey = "";
var city = "London";
fetch("https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=" + apikey)
.then(function(response) {
vm.weather = response.main.temp;
console.log("weather: "+ vm.weather);
return response.json();
})
.then(function(myJson) {
console.log(myJson);
});
}
});
```
```
<weather-component></weather-component>
<script src="utils.js"></script>
<script src="weather.component.js"></script>
```
In utils it is initialized var myApp = angular.module('myApp', []);
API响应URL:https://openweathermap.org/current
我正在学习js提取。我正在尝试从响应中获取temp的值并将其显示在我的component.js weather.component.js```myApp.component('weatherComponent',{...