2017-04-06 42 views
-3

我得到以下错误**(angular.js:14525 TypeError:$ http。 post(...)。成功不是函数atChildScope.BindingCode。$ scope.Submit(ClientSide.html:36)at fn(eval at compile(angular.js:15358),:4:138))** while执行这段代码。这段代码被发送到物体向asp.net的WebAPI和处理之后获得的数据背

$scope.Submit = function() { 
        if($scope.Customer.CustomerName.length==0) 
        { 
         alert("Not a proper data"); 
        } 
        else 
        { 
         $http.post("http://localhost:59040/api/Customer", $scope.Customer). 
          success(function (data) { 
          $scope.Customer = data; 
         }); 
        } 
       } 

回答

0

我没有得到相同的错误在具有角+ asp.net-的WebAPI的类似的解决方案。该错误与angular的版本有关。

“成功” 功能在角1.6.2版

不赞成在这种情况下,正确的sintax

$scope.Submit = function() { 
       if($scope.Customer.CustomerName.length==0) 
       { 
        alert("Not a proper data"); 
       } 
       else 
       { 
        $http({ 
         method: 'POST', 
         url: 'http://localhost:59040/api/Customer' 
        }).then(function successCallback(data) { 
         $scope.Customer = data; 
        }, function errorCallback(response) { 
         console.log(response); 
        }); 
       } 
      } 
相关问题