0
テキストフィールドからJSON文字列で情報を渡しています。質問ごとに1つの回答があり、複数の顧客が同じ質問に答えています。私が抱えている問題は、情報がネットワークコンソールのリクエストペイロードに渡されていることです。しかし、私はC#コントローラクラスの私のリストでそれを見ていません。リクエストペイロードにデータがコントローラ内にないと表示されます
以下にSysIntClientsリストが流れるされていないコントローラ内のリストのデバッグです。しかし、ネットワークの応答ペイロードから通じ来ている:
次のように私のNG-repeatが見えます:次のように
<div class="row" ng-repeat="question in Question" ng-if="question.SI_ID == '1'">
<div class="col-lg-6">
<label class="labelQuestion" id="question_label" for="question_answer">{{question.QID}}: {{question.Question1}}</label>
</div>
<div class="row">
<div class="col-lg-6">
<input type="{{question.input_type}}" ng-model="question.SysIntClients.Answer" class="form-control" ng-style="{'height': question.input_type == 'radio' ? '20px' : '40px'}" name="question_answer" id="question_answer" required {{question.SysIntClients.Answer}}
</div>
</div>
</div>
私の角度のコードでは、なります
$scope.SysIntClients =
[{
Answer: ''
}]
$scope.Question = [{
QID: '',
SI_ID: '',
Question1: '',
input_type: '',
SysIntClients: [{
Answer: ''
}]
}]
var array = [];
array = $scope.Question;
alert("Thank you for your input. Now saving data.");
//Save Data
//$scope.sendForm = function (Courier, Customer, Integration, intCapabilities, Retailer) {
$log.log("in the save data function");
$log.log("Form is valid");
//$scope.Courier = Courier; // in order to pass to the reg service in var data
//$scope.Customer = Customer;
//$scope.Integration = Integration;
//$scope.intCapabilities = intCapabilities;
//$scope.Retailer = Retailer;
//var submitData = registrationService.SaveFormData($scope.Courier, $scope.Customer, $scope.Integration, $scope.intCapabilities, $scope.Retailer);
$log.log("in registration service");
//var fac = {};
//fac.SaveFormData = function (Courier, Customer, Integration, intCapabilities, Retailer) {
$log.log("array: " + array);
$log.log("array length: " + array.length);
$log.log("Question: " + $scope.Question);
$log.log("in fac.SaveFormData");
var defer = $q.defer();
var postToAction = $http({
url: '/Home/RegisterUser',
method: 'POST',
data: JSON.stringify({ 'Courier': $scope.Courier, 'Customer': $scope.Customer, 'Station': $scope.Station, 'Integration': $scope.Integration, 'intCapabilities': $scope.intCapabilities, 'Question': array }),
headers: { 'content-type': 'application/json' }
});
誰かが私のSysIntClient.Answer変数が引き抜かれていない理由を知っていますか?
'SysIntClients'はプロパティです(' {get; set;} ')? –
はい、そうです。これは、 "質問"と呼ばれるC#エンティティフレームワーククラスからSysIntClientsを呼び出しています。次のコード行があります。 'public Question() { this.SysIntClients = new HashSet(); }パブリック仮想ICollection SysIntClients {get;セット; } ' –
user1397978
リクエストペイロードは、' SysIntClients'がコレクションではなくオブジェクト( 'Answer'という名前のプロパティを含む)であることを示唆しています。 –