-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (24 loc) · 841 Bytes
/
Copy pathapp.js
File metadata and controls
30 lines (24 loc) · 841 Bytes
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
var weatherApp = angular.module("weatherApp", ['ngRoute', 'ngResource']);
weatherApp.config(function($routeProvider){
$routeProvider.when("/", {
templateUrl: "./Pages/Home.html",
controller: "homeController"
})
.when("/forecast", {
templateUrl: "./Pages/Forecast.html",
controller: "forecastController"
});
});
weatherApp.service('cityService', function() {
this.city = "New York, NY";
});
weatherApp.controller("homeController", ["$scope" ,"cityService", function($scope, cityService) {
$scope.city = cityService.city;
$scope.$watch("city", function() {
cityService.city = $scope.city;
})
}]);
weatherApp.controller("forecastController", ["$scope", "cityService", function($scope, cityService) {
$scope.city = cityService.city;
$scope.test = "test";
}]);