2016-07-18 15 views
1

私は天気予報Webアプリケーションを角度jで作成しています。 以下は私の小さなコードです。私は2つのエラー取得しています

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); 


}]); 

Uncaught SyntaxError: Unexpected identifier app.js:41 

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

を私はすべての可能な機能を追加したが、それでもその取得中にエラー.. は、誰かがこれで私を助けることができます。

+0

ライン41は何か? –

+0

'appid'は文字列のように見えますが、その周りに引用符はありません。 – Lex

+0

appidは気象APIを使用するためにキーが生成されています。引用符でも同じエラーがコード化されています – Walberg

答えて

1

この:appid: 9fc927759b42ed332b58471398219df0

は次のようになります。appid: '9fc927759b42ed332b58471398219df0'

+0

thanks..It worked..thanks a lot .. – Walberg

関連する問題