angular在编译时报错如下:
Error: [ng:areq] http://errors.angularjs.org/1.5.5/ng/areq?p0=MainCtr1&p1=not%20a%20function%2C%20got%20undefined
at angular.min.js:6
at qb (angular.min.js:23)
at Pa (angular.min.js:23)
at angular.min.js:89
at O (angular.min.js:72)
at n (angular.min.js:64)
at g (angular.min.js:58)
at g (angular.min.js:58)
at angular.min.js:57
at angular.min.js:21
(anonymous) @ angular.min.js:117
原代码:js:
var app=angular.module('Weather',[]);
app.factory('WeahterApi',function($http){
var obj={};
obj.getIP = function(){
return $http.jsonp("http://ipinfo.io/json?callback=JSON_CALLBACK");
}
obj.getCurrent = function(ip){
var api="http://v.juhe.cn/weather/ip?format=1";
var APPKey="&key=47f4bdd330534e7917a3cc2c756e5078&ip=";
var cb="&callback=JSON_CALLBACK";
return $http.jsonp(api+APPKey+ip+cb);
};
return obj;
});
app.controller('MainCtrl',function($scope,WeatherApi){
$scope.Data={};
WeatherApi.getIP().success(function(data){
var ip=data.ip;
WeatherApi.getCurrent(ip).success(function(data){
$scope.Data=data.result;
$scope.items=data.result.future;
delete $scope.items[Object.keys($scope.items)[0]];
});
});
});
自己看
文字书写错误
app.factory('WeahterApi',
改成
app.factory('WeatherApi',