Shubham Bhardwaj
Shubham Bhardwaj

Reputation: 155

"TypeError: v2.email is not a function"

This function works the first time I call it, but gives this error 2nd time onwards
It starts working again once I refresh It

AngularJs

 $scope.email = function(){
    $scope.email=$scope.user.email;
    data = { "email": $scope.email }
    console.log(data);
    $http.post("http://localhost:8080/"+url2, data, config).then(
    function(response){
        console.log(response);
        $scope.reply = response.data;
        },
        function(response){
            console.log(response);
        });
}

HTML

  <div class="form-group">
    <label class="control-label">&emsp;Email:</label><br>
    <div class="col-lg-10">
      <input class="form-control" type="text" ng-model="user.email" placeholder="[email protected]">
      <a href="" ng-click="email()">(Change)</a>
    </div>
  </div>

Upvotes: 2

Views: 758

Answers (1)

iuliu.net
iuliu.net

Reputation: 7145

Your anonymous function inside $scope.email redefines and overrides the actual $scope.email function property. You have a naming conflict.

Rename your function to something like $scope.getEmail()

Upvotes: 1

Related Questions