我想在我的表单字段中像这样封存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">კომპანიის სახელი ლათინურად</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">კომენტარი უარზე</label>
<input type="text"
class="form-control"
cam-variable-type="String"
cam-variable-name="refusalComment"
name="კკომენტარი უარზედ"/>
</div>
</div>
但是这似乎不够,我应该改变什么才能将这个json数据显示到我的表单中?我应该使用ng-for而不是ng-repeat?
(p.s控制台中没有任何内部错误)
答案 0 :(得分:-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">
如果有帮助,请告诉我。