0

How would I be able to collect all the data from the table then parse it into a JSON so I could then write it to a properties file?

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>

JS

$scope.changeProp(){
    //collect data then parse as JSON
};
0

2 Answers 2

2

Switch your value={{value}} to ng-model="value", this way your data will be automatically updated when you change values and you should just be able to call angular.toJson($scope.configResources) when you want to convert it into a JSON.

Sign up to request clarification or add additional context in comments.

Comments

0

switch

<input type="text" value={{value}}>

to

<input type="text" ng-model="value" />

and then, do the following:

$scope.changeProp(){
     var myJson = angular.toJson($scope.configResources);
};

Comments