Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS从表中收集数据-解析为JSON_Javascript_Angularjs_Json - Fatal编程技术网

Javascript AngularJS从表中收集数据-解析为JSON

Javascript AngularJS从表中收集数据-解析为JSON,javascript,angularjs,json,Javascript,Angularjs,Json,如何从表中收集所有数据,然后将其解析为JSON,以便将其写入属性文件 HTML <table class="table"> <thead> <tr> <th>Key</th> <th>Value</th> </tr> </thead> <tbody> <

如何从表中收集所有数据,然后将其解析为JSON,以便将其写入属性文件

HTML

<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);
};