1

I am making weather forecast web app using angular js. Below is my little piece of code.

var myApp = angular.module("myApp", ["ngRoute", "ngResource"]);

myApp.config(function($routeProvider){

$routeProvider

.when('/',{
      templateUrl : 'pages/home.htm',
      controller : 'homeController'
      })

.when('/forecast',{
      templateUrl : 'pages/forecast.htm',
      controller : 'forecastController'
      })

});

myApp.service("cityService", function(){

})


myApp.controller("homeController", ['$scope','cityService', function($scope,cityService){
$scope.city = cityService.city;
$scope.$watch('city', function(){
    cityService.city = $scope.city;
});



}]);


myApp.controller("forecastController", ['$scope','$resource','cityService', function($scope,$resource,cityService){
$scope.city = cityService.city;
$scope.weatherAPI =
    $resource("http://api.openweathermap.org/data/2.5/weather",{
    callback : "JSON_CALLBACK" }, {get : {method : "JSONP" }});
//below is line 41
$scope.weatherResult = $scope.weatherAPI.get({ q: $scope.city, appid: 9fc927759b42ed332b58471398219df0});
console.log($scope.weatherResult);


}]);

I am getting two errors:

Uncaught SyntaxError: Unexpected identifier  app.js:41

Uncaught Error: [$injector:modulerr]    angular.js:38 .

I have added every possible function, but still its getting error.. Can someone help me out with this.

3
  • appid looks like a string, but you don't have quotes around it. Commented Jul 18, 2016 at 20:06
  • appid is key generated for using weather apis..and i have encoded that in quotes, still same errors Commented Jul 18, 2016 at 20:11
  • i hav edited and mentioned line 41 Commented Jul 18, 2016 at 20:13

1 Answer 1

1

This: appid: 9fc927759b42ed332b58471398219df0

Should be: appid: '9fc927759b42ed332b58471398219df0'

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.