Reputation: 155
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"> 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
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