Javascript 使用AngularJS将隐藏值传递给JSON
Im basic开发人员,只想在json数组中传递html页面中的隐藏值。以下是我的密码: Index.htmlJavascript 使用AngularJS将隐藏值传递给JSON,javascript,json,angularjs,Javascript,Json,Angularjs,Im basic开发人员,只想在json数组中传递html页面中的隐藏值。以下是我的密码: Index.html <!doctype html> <html ng-app="plunker" > <head> <meta charset="utf-8"> <title>AngularJS Plunker</title> <script>document.write('<b
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controller="WorkingCtrl">
<h1 ng-bind="vm.heading"></h1>
<form name="myForm" novalidate>
<b> Text: </b>
<input ng-model="form.text" required /><br>
<button ng-click="submitForm()" bng-disabled="myForm.$invalid">Click Me!</button>
</form>
<p ng-bind="showValues"></p>
</div>
</body>
</html>
现在,来自ng model=“form.text”
的值成功返回未隐藏输入类型的结果
{ "text":"What_ever_text" }
但是如何在数组中发送定义的值,包括隐藏的输入类型,如:-
<input value="99999" type="hidden" ng-model="form.userid" required />
有解决办法吗?
注意:-输入类型应隐藏或任何其他更简单的方法。提前感谢。隐藏输入字段的工作原理与普通字段相同 请参阅下面的代码
var-app=angular.module('myApp',[]);
app.controller('WorkingCtrl',['$scope','$http',函数($scope,$http){
$scope.form={
文字:“一些测试”,
用户ID:'12312'
};
$scope.submitForm=函数(){
$scope.showValues=JSON.stringify($scope.form);
}
}]);代码>
正文:
点击我!
谢谢:)得到了我想要的
<input value="99999" type="hidden" ng-model="form.userid" required />
{ "text":"What_ever_text" , "userid":"99999" }