0
我正在開發Angularjs應用程序,我有一個要求,即必須將隱藏變量發送給第三方應用程序。在angularjs中動態創建隱藏字段
這些隱藏變量的值應該來自數據庫。
我正在使用以下代碼動態創建隱藏變量。當用戶點擊提交按鈕
$scope.getDetailsForTP = function() {
$scope.models.MyModel.templateVariables = {};
$http({
url: "http://localhost:11149/MyService.svc/TemplateVariable",
dataType: "json",
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
}).then(function successCallback(response) {
if (response.status == 200) {
$scope.models.MyModel.templateVariables = response.data;
$scope.submitForm();
}
else {
alert('Error occurred in fetching template variable data');
}
}, function errorCallback(response) {
//do something
});
};
$scope.submitForm = function() {
document.getElementById("apirequest").submit();
};
隱變量在頁面上正確地呈現,但是當我檢查提琴手我找不到提交的隱藏變量
<input type="hidden" ng-repeat="hdnvar in models.MyModel.templateVariables" name="{{hdnvar.Key}}" id="{{hdnvar.Key}}" value="{{hdnvar.Value}}" />
Follwing函數被調用。
有人可以幫忙嗎?
你爲什麼要提交你的表格。您可以使用$ http服務發佈您的數據,並在請求的數據字段中傳遞您的模態數據(數組)。 –
感謝您的評論。你能否提供一個例子來做到這一點? –