Javascript AngularJS从表中收集数据-解析为JSON
如何从表中收集所有数据,然后将其解析为JSON,以便将其写入属性文件 HTMLJavascript AngularJS从表中收集数据-解析为JSON,javascript,angularjs,json,Javascript,Angularjs,Json,如何从表中收集所有数据,然后将其解析为JSON,以便将其写入属性文件 HTML <table class="table"> <thead> <tr> <th>Key</th> <th>Value</th> </tr> </thead> <tbody> <
<table class="table">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in configResources">
<td>{{key}}</td>
<td><input type="text" value={{value}}></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" ng-click="changeProp()"></button>
将您的
value={{value}}
切换到ng model=“value”
,这样,当您更改值时,您的数据将自动更新,并且当您想要将其转换为JSON时,您应该只能够调用angular.toJson($scope.configResources)
。将您的value={{value}
切换到ng model=“value”
,这样,当您更改值时,您的数据将自动更新,并且当您想要将其转换为JSON时,您应该能够调用angular.toJson($scope.configResources)
。开关
<input type="text" value={{value}}>
开关
<input type="text" value={{value}}>
<input type="text" ng-model="value" />
$scope.changeProp(){
var myJson = angular.toJson($scope.configResources);
};