I am currently working on developing an application with the following code snippet:
function attendeeCtrl($scope, $http) {
$scope.submit = function () {
console.log($scope.noattendees);
$http({
method: 'POST',
url: 'http://localhost:2000/data',
data: {
event: $scope.event,
date: $scope.date,
spentby: $scope.spentby,
amountspent: $scope.amountspent
},
});
};
}
<div ng-app>
<h2>Team share</h2>
<div ng-controller="attendeeCtrl">
<label for="amountspent">Amount spent(Rs)</label>
<input type="text" name="amountspent" id="amountspent" ng-model="amountspent" />
<br>
<label for="noattendees">Number of attendees</label> <span name="noattendees" id="noattendees" ng-model="noattendees">{{remaining()}}</span>
</br>
<label for="amountshared">Amount Shared</label><span ng-model="amountshared" name="amountshared" id="amountshared">{{amountspent/(remaining()+1)}}</span>
</br>
<input type="submit" id="submit" value="Submit" ng-click="submit()" />
<input type="reset" id="reset" value="Reset" />
</div>
</div>
However, when I use console.log($scope.noattendees)
, it is showing "undefined".
Can anyone suggest how to retrieve the value of {{return()}}
in the submit method?