繁体   English   中英

AngularJS表单数据未存储在数据库中

[英]Angularjs form data not storing in database

我正在尝试通过angularjs将表单数据存储到数据库中,但没有存储到数据库中。 不知道我在做什么错吗?

我的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>

我的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");
        });
    };

}]);

我收到警报“成功创建挑战”,但是数据未存储到数据库中。 任何帮助都非常感谢!

例如,请验证此请求映射/ccp-services/userchallenge/create模型变量可能在您的模型对象名称中与您在angularjs中创建的名称完全不同。 因此,请确保模型变量名称应与UI模型变量的名称相同,然后仅将其绑定数据并对其进行处理。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM