I have an HTML file with a form and json file with the following structure:
[
{
"airline" : "British Airways",
"hub" : "LHR",
"url" : "http://britishairways.com",
"callsign":"SPEEDBIRD"
},
{
"airline" : "Air France",
"hub" : "CDG",
"url" : "http://airfrance.com",
"callsign":"AIRFRANS"
},
{
"airline" : "Virgin Atlantic",
"hub" : "LGW",
"url" : "http://virginatlantic.com",
"callsign":"VIRGIN"
},
{
"airline" : "RyanAir",
"hub" : "DUB",
"url" : "http://ryanair.com",
"callsign":"RYANAIR"
},
{
"airline" : "ANA",
"hub" : "HND",
"url" : "http://ana.com.jp",
"callsign":"ALL NIPPON"
},
{
"airline" : "Flydubai",
"hub" : "DXB",
"url" : "http://flydubai.com",
"callsign":"SKY DUBAI"
}
]
AngularJS parameters: ng-app="ajsprogram", ng-controller="outercont".
How do I add a new data to it from my form through a function on submit?
The data structure is pretty much the same:
"airline" : "Emirates",
"hub" : "DXB",
"url" : "http://emirates.com",
"callsign":"EMIRATES"
.pushon the Array. For more information, see MDN JavaScript Reference - Array push().