-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrollers.js
45 lines (30 loc) · 1.22 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Created by Joy on 4/13/16.
*/
// Angular Controller
weatherApp.controller('cityCtrl',['$scope','cityService','$location' ,function ($scope, cityService, $location) {
$scope.cityName = cityService.cityName;
$scope.$watch('cityName', function () {
cityService.cityName= $scope.cityName;
});
$scope.submit = function () {
$location.path("/forecast")
};
}]);
weatherApp.controller('forecastCtrl',['$scope','$routeParams' ,'cityService','weatherService' ,function ($scope, $routeParams, cityService, weatherService) {
$scope.cityName = cityService.cityName;
$scope.days = $routeParams.days || '2';
$scope.weatherResult = weatherService.getWeather($scope.cityName, $scope.days);
// $scope.productAPI = $resource("https://1009f2d2b6e696cf4f0f6472af5873d9:[email protected]/admin/products.json");
//
// $scope.productResult = $scope.productAPI.get();
//
// console.log(productResult);
// console.log($scope.weatherResult);
$scope.convertToFahrenheit = function (degK) {
return Math.round((1.8 * (degK - 273)) + 32);
};
$scope.convertToDate = function (dt) {
return new Date(dt * 1000)
};
}]);