[英]Angularjs form data not storing in database
I am trying to store form data into database through angularjs but it is not storing into the database. 我正在尝试通过angularjs将表单数据存储到数据库中,但没有存储到数据库中。 Don't know what I am doing wrong?
不知道我在做什么错吗?
My html form 我的HTML表单
<form id="challenge_form" class="row" >
<input type="text" placeholder="Challenge Name" ng-model="challengeName" />
<select class="btn-group form-control" id="sel1" ng-model="challengeType">
<option>-- Select Activity Type --</option>
<option value="running">Running</option>
<option value="walking">Walking</option>
<option value="cycling">Cycling</option>
</select>
<input type="date" placeholder="Start Date" ng-model="startDate" />
<input type="date" placeholder="End Date" ng-model="endDate" />
<input type="button" class="btn btn-theme" ng-click="newChallenge()" value="Decide Prize">
<input type="button" class="btn btn-theme" value="Cancel">
</form>
My angularjs controller 我的angularjs控制器
app.controller("NewChallengesController", ["$http", "$scope", "authenticationSvc", function ($http, $scope, authenticationSvc) {
//alert("hello, inside New Challenge Controller");
var token = authenticationSvc.getUserInfo();
var config = {
headers: {
'h5cAuthToken': token.accessToken,
'Accept': 'application/json;odata=verbose'
}
};
$scope.newChallenge = function () {
var data = {
"challengeName": $scope.challengeName,
"selectedRewardId": "283081",
"startDate": $scope.startDate,
"endDate": $scope.endDate,
"activityCategoryId": 51,
"minParticipant": 0,
"referredNumbers": "9876543213",
"distance": 15.0,
"challengeType": $scope.challengeType
};
$http.post("http://103.19.89.152:8080/ccp-services/userchallenge/create", data, config).then(function (response) {
alert("challenge created successfully");
});
};
}]);
I am getting the alert "challenge created successfully" but data is not storing into the database. 我收到警报“成功创建挑战”,但是数据未存储到数据库中。 Any help is highly appreciated!!
任何帮助都非常感谢!
For Example , Please verify this request mapping /ccp-services/userchallenge/create
model variable might be in your model object name is totally different what you have created in angularjs. 例如,请验证此请求映射
/ccp-services/userchallenge/create
模型变量可能在您的模型对象名称中与您在angularjs中创建的名称完全不同。 So please make sure the model variable name should be same name of UI model variable then only its bind the data and Process it. 因此,请确保模型变量名称应与UI模型变量的名称相同,然后仅将其绑定数据并对其进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.