I am trying to update a JSON file with data entered in form elements, but I seem to be encountering some issues.
<html ng-app="example">
<div ng-controller="ListController">
<form name="myform" ng-submit="addThis()">
<input type="text" ng-model="model1">
<input type="text" ng-model="model2">
</form>
</div>
</html>
JS:
var app = angular.module('example', []);
app.controller('ListController', ["$scope", "$http", function($scope) {
$http.get("_/js/data.json").success(function(data) {
$scope.mydata = data;
});
$scope.addThis = function() {
$scope.mydata.push({
model1:$scope.mydata.keyname1,
model2:$scope.mydata.keyname2
});
};
}]);
I'm having trouble understanding what's causing the issue. Can someone help?