- Для получения элемента из json:
controller.weather = response.weather[0].description;
Способ решить эту проблему: создать сервис, чтобы я мог получить данные и изменить компонент. Я отказываюсь от идеи использовать "fetch".
weather.service. js
```myApp.service('weatherService', function($http, $q) {
this.getWeather = function (apikey, city) {
var deferred = $q.defer();
// HTTP call
$http.get("https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=" + apikey)
.then(function(response) {
deferred.resolve(response.data);
}, function(response){
deferred.reject(response);
});
return deferred.promise;
};
});
```
weather.component. js
```
myApp.component('weatherComponent', {
template:"<p>Weather: {{weather}}</p>",
controllerAs: 'vm',
controller: function WeatherController($scope, weatherService, $element, $attrs) {
var apikey = "b441194a96d8642f1609a75c1441793f";
var city = "London";
var controller = $scope;
controller.weather = "None";
weatherService.getWeather(apikey, city).then(function(response) {
controller.weather = response.weather[0].description;
});
}
});
```