老师,请帮我指正一下这个报错,谢谢!
这是http.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 'use strict' ; angular.module( 'app' ).config([ '$provide' , function ($provide){ $provide.decorator( '$http' , [ '$delegate' , '$q' , function ($delegate, $q){ $delegate.post = function (url, data, config) { var def = $q.defer(); $delegate.get(url).then( function (res){ def.resolve(res); }, function (err){ def.reject(err); }); return { success: function (cb){ def.promise.then(cb); }, error: function (cb) { def.promise.then( null , cb); } } } return $delegate; }]); }]); |
这是registerCtrl.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 'use strict' ; angular.module( 'app' ).controller( 'registerCtrl' ,[ '$interval' , '$http' , '$scope' , '$state' , function ($interval,$http,$scope,$state){ $scope.submit = function (){ $http.post( 'data/regist.json' ,$scope.user).then( function successCallback(res){ console.log(res.data); }, function errCallback(err){ console.log(err); }); } var count = 60; $scope.send = function (){ $http.get( 'data/code.json' ).then( function successCallback(res){ if (1 === res.data.state){ count = 60; $scope.time = '60s' ; var interval = $interval( function (){ if (count <=0){ $interval.cancel(interval); $scope.time = '' ; } else { count --; $scope.time = count + 's' ; } },1000); } }); } }]); |
以下是浏览器报错截图
我已经用的是then的方法发起请求的,不明白哪里出了问题,望老师看下,谢谢1