I am developing an app as follows
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>
But console.log($scope.noattendees)
returns "undefined"
How to get the value of {{return()}}
in the submit method? Please advice
To get the return value from the server:
$http({method: 'GET', url: '/someUrl'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.