javascript - Angular JS 未捕获错误 : [$injector:modulerr] uncaught error

标签 javascript angularjs

我正在使用 Angular JS 制作天气预报网络应用程序。 下面是我的一小段代码。

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 .

我已经添加了所有可能的功能,但仍然出现错误.. 有人可以帮我解决这个问题吗?

最佳答案

这个:appid:9fc927759b42ed332b58471398219df0

应该是:appid:'9fc927759b42ed332b58471398219df0'

关于javascript - Angular JS 未捕获错误 : [$injector:modulerr] uncaught error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38445063/

相关文章:

javascript - 如何使用 TinyMCE 上传图像?

javascript - 来自 36 个字符字母表的加密安全字符串?

javascript - 如何检测每个页面的加载情况?

javascript - PHP 端的 JWT

html - 在 html 输入标签的值属性内执行 angularjs 操作

javascript - 如何使用 Angular Js 重定向页面?

javascript - React 期望一个赋值或函数调用,但看到一个表达式

javascript - Vue js - 多个组件,每个组件都有不同的初始选择值

php - laravel - 从 http 请求中获取参数

javascript - Angular UI-Router 嵌套 View