-
Notifications
You must be signed in to change notification settings - Fork 0
/
controllers.js
30 lines (20 loc) · 911 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
weatherApp.controller('homeController',['$scope','cityService','$location',function($scope,cityService,$location){
$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,$scope.days);
$scope.convertToDate= function(dt){
var utcSeconds = dt;
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
d.setUTCSeconds(utcSeconds);
return d;
}
}]);