2016-07-08 6 views
0

angularjs를 통해 데이터베이스에 양식 데이터를 저장하려고했지만 데이터베이스에 저장하지 않습니다. 내가 뭘 잘못하고 있는지 몰라?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"); 
     }); 
    }; 

}]); 

내가 경고 "도전에 성공적으로 만들어"하지만 데이터가 데이터베이스에 저장되지 않습니다 얻고있다. 어떤 도움을 주셔서 감사합니다 !!

+0

서버 측에서 무슨 일이 일어나고 있는지 확인하십시오. 또한 응답을 콘솔보십시오. –

+0

데이터를 게시 할 서비스에 중단 점을 넣으십시오. 또한 응답 코드가 피들러에서 반환되는지 확인하십시오. –

답변

1

예를 들어, 이 요청 매핑 /ccp-services/userchallenge/create 모델 변수가 모델 객체 이름에 수 있습니다 확인하십시오하면 AngularJS와에서 만든 것을 완전히 다르다. 따라서 모델 변수 이름이 UI 모델 변수의 이름과 동일해야하고 데이터 변수 만 바인드하고 처리해야합니다.

+0

감사합니다. @SakthiSureshAnand, –

관련 문제