Hi, i have just started learning Angular js. I find difficulty in adding the data to an existing JSON file.
This is my JSON file
{"response":[ {
"Cust_Fname":"Jack",
"Cust_Lname":"Nicolson",
"Cust_Dob":"24/09/1992",
"Cust_Mob":"0987654321",
"Cust_Email":"abc@xyz.com
},
{
"Cust_Fname":"tom",
"Cust_Lname":"cruise",
"Cust_Dob":"19/01/1990",
"Cust_Mob":"1234567890",
"Cust_Email":"sss@gmail.com",
}
]
}
This is my AngularJS code to push data
$scope.saveContact = function(contact){
$http.post('/data/Cust_Dtls.json',contact).success(function(data, status, headers, config){
console.log(data)});
}
This is my HTML file
<ion-content class="item-noborder base-bg" overflow-scroll="true" padding="true">
<div class="row" >
<div class="col-50 pane-top-padding-20" style="padding-left:10px"><a class="button button-icon button-positive ion-arrow-left-c" href="#/tab/contacts"> Back to Contacts</a></div>
<div class="col-50 pane-top-padding-20 text-right"><a class="button button-icon button-positive ion-checkmark text-right" href="#/tab/contacts" ng-click="saveContact(contact)"> Save</a></div>
</div>
<div id="contact-div">
<label class="item">
<span class="input-label">First Name</span>
<input type="text" placeholder="First Name" ng-model="contact.Cust_Fname">
</label>
<label class="item">
<span class="input-label">Last Name</span>
<input type="text" placeholder="Last Name" ng-model="contact.Cust_Lname">
</label>
<label class="item">
<span class="input-label">Email</span>
<input type="text" placeholder="Email" ng-model="contact.Cust_Email">
</label>
<label class="item">
<span class="input-label">Phone</span>
<input type="text" placeholder="Phone" ng-model="contact.Cust_Mob">
</label>
<label class="item">
<span class="input-label">Date Of Birth</span>
<input type="text" placeholder="DOB" ng-model="contact.Cust_Dob">
</label>
</div>
</ion-content>
I am unable to save the data into the JSOn file. i will glad if anyone could help me.
Thanks
Venkatesh