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服务发布您的数据,并在请求的数据字段中传递您的模态数据(数组)。 –
感谢您的评论。你能否提供一个例子来做到这一点? –