-
Notifications
You must be signed in to change notification settings - Fork 0
/
controllers.js
32 lines (22 loc) · 935 Bytes
/
controllers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// CONTROLLERS
weatherApp.controller('homeController', ['$scope', '$location', 'cityService', function($scope, $location, cityService) {
$scope.city = cityService.city;
$scope.$watch('city', function() {
cityService.city = $scope.city;
});
$scope.submit = function() {
$location.path("/forecast")
};
}]);
weatherApp.controller('forecastController', ['$scope', '$routeParams', 'cityService', 'weatherService', function($scope, $routeParams, cityService, weatherService) {
$scope.city = cityService.city;
$scope.days = $routeParams.days || '2';
$scope.weatherResult = weatherService.GetWeather($scope.city);
//console.log($scope.weatherResult);
$scope.convertToF = function(degK) {
return Math.round((1.8 * (degK - 273)) + 32);
}
$scope.convertToDate = function(dt) {
return new Date(dt);
}
}]);