1

我想在我的表单字段中像这样对 json 进行序列化:

 {FinalResult: [{"id":1,"organizationNameGE":"პსდა2","organizatio…":"02-16-2018","$$hashKey":"0Q0","priority":"1"}]"}

出于这个原因,我使用以下代码:

<script cam-script type="text/form-script">

    camForm.on('form-loaded', function() {
      // tell the form SDK to fetch the variable named 'document'
      camForm.variableManager.fetchVariable('selectedDocuments');
    });
    camForm.on('variables-fetched', function() {
      // work with the variable (bind it to the current AngularJS $scope)
      $scope.selectedDocuments =ConvertToJsonArray(camForm.variableManager.variableValue('selectedDocuments'));

    });
function ConvertToJsonArray(arr){
var jsonArray=arr.FinalResult;
return jsonArray;
}
  </script>
<div class="container" ng-repeat="item in selectedDocuments track by $index">
<div class="control-group"  >
    <label for="id" class="control-label">საიდენტიფიკაციო კოდი</label>
     <div class="controls">
      <input id="id" class="form-control" type="number" ng-model="item.id" required  readonly/>
    </div>
  </div>
    <div class="control-group" >
    <label for="cardNumber" class="control-label">ბარათის ნომერი</label>
    <div class="controls">
      <input id="cardNumber" class="form-control" type="text" ng-model="item.cardNumber" required />
    </div>
  </div>
   <div class="control-group"  >
    <label for="organizationNameGE" class="control-label">კომპანიის სახელი ქართულად</label>
    <div class="controls">
      <input id="organizationNameGE" class="form-control" type="text" ng-model="item.organizationNameGE" required />
    </div>
  </div>
      <div class="control-group"  >
    <label for="organizationNameEN" class="control-label">კომპანიის სახელი ლათინურად&lt;/label>
   <div class="controls">
      <input id="organizationNameEN" class="form-control" type="text" ng-model="item.organizationNameEN" required />
    </div>
  </div>    
   <div class="control-group" >
    <label for="Approved" class="control-label">Approved</label>  
   <input type="checkbox"
       class="form-control" 
       cam-variable-name="Approved"
       cam-variable-type="Boolean"/> 
       </div>       
      <div class="form-group">
      <label for="refusalComment" class="control-label">კომენტარი უარზე&lt;/label>
      <input type="text"
           class="form-control" 
           cam-variable-type="String"
           cam-variable-name="refusalComment"
           name="კკომენტარი უარზედ"/>
            </div> 
            </div> 

但这似乎还不够,我应该改变什么来将这个 json 数据显示到我的表单中?我应该使用 ng-for 而不是 ng-repeat 吗?

(ps控制台中没有任何内部错误)

4

1 回答 1

-1

看起来您正在数组 FinalResult 中获取数据。我不确定您为什么使用 selectedDocuments 。

<div class="container" ng-repeat="item in selectedDocuments track by $index">

使用它而不是 selectedDocuments

<div class="container" ng-repeat="item in FinalResult track by $index">

如果有帮助,请告诉我。

于 2018-02-21T07:13:22.690 回答