我不知道为什么当我按提交时我总是得到Error: Cannot call method 'post' of undefined
,请帮助
HTML:
<div data-ng-controller="HeaderController">
<form ng-submit="findFriend()">
<input type="email" ng-model="friendEmail">
<input type="submit" value="Find">
</form>
</div>
脚本:
angular.module('mean.system').controller('HeaderController', ['$scope', 'Global', '$http', function ($scope, Global, $timeout, $http) {
$scope.findFriend = function() {
$scope.email = this.friendEmail;
console.log($scope.email)
$http.post('/findfriend', $scope.email).success(function(data) {
$location.path('/findfriendresult');
})
}
}]);
答案 0 :(得分:0)
问题在于控制器声明中的参数计数
angular.module('mean.system').controller('HeaderController', ['$scope', 'Global','$timeout', '$http', function ($scope, Global, $timeout, $http) {
缺少'$timeout'