angular.js - 使用Angualr编译时报错 Error: [ng:areq] http://errors.angularjs.org/....
巴扎黑
巴扎黑 2017-05-15 17:12:27
0
2
1151

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]];
        });
    });
});
   
巴扎黑
巴扎黑

reply all(2)
我想大声告诉你

See for yourself

给我你的怀抱

Text writing error
app.factory('WeahterApi',
changed to
app.factory('WeatherApi',

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!