User is not defined Angular js

前端 未结 2 1186
我在风中等你
我在风中等你 2021-01-24 12:05

i have a problem when i click in the button it give me an error that user is not defined i don\'t know what the problem



        
相关标签:
2条回答
  • 2021-01-24 12:07

    You are not passing anything to the function $scope.Active. Pass the User:

    $scope.Active = function(User) {...}
    
    0 讨论(0)
  • 2021-01-24 12:07

    The datatype property is ignored by the AngularJS framework. Also it is not necessary to stringify JavaScript objects. The AngularJS framework does that automatically.

    $scope.Active = function(user) {  
        $http({
            method: "post",  
            url: "http://localhost:61484/AspNetUsers/Active",  
            ̶d̶a̶t̶a̶t̶y̶p̶e̶:̶ ̶"̶j̶s̶o̶n̶"̶,̶
            ̶d̶a̶t̶a̶:̶ ̶J̶S̶O̶N̶.̶s̶t̶r̶i̶n̶g̶i̶f̶y̶(̶U̶s̶e̶r̶)̶ 
            data: user  
        }).then(function(response) {  
            alert(response.data);  
            $scope.GetAllData();  
        })  
    };
    

    For more information, see

    • AngularJS $http Service API Reference
    0 讨论(0)
提交回复
热议问题