Can you store images to a local app directory img/airports/<image.jpg>
using only angular, html, javascript/jQuery? if so, whats the best method to not only upload the image but also push the path to the json file upon ng-submit?
I am not using a proper DataBase(MongoDB) nor a backend framework(expressJS), I'm Using Yeoman's angular-generator. In the end, I'm trying to create a very basic cms, which communicates via JSON. So I need to store the image and push a JSON object to a model called Airports. All my data is stored in a factoryService which stored as a set of JSON objects, with exception of course to the image.
angApp.factory("Airports", function() {
var Airports = {};
Airports.detail = {
"JFK": {
"slug": "JFK",
"name": "John F Kennedy",
"img": "img/airports/jfk.jpg",
"section": [
{
"sectionTitle" : "About",
"copy": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tristique, purus euismod tincidunt "
},
{
"sectionTitle" : "Learn more",
"copy": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. 222"
}
]
}
};
return Airports;
});
Controller:
angular.module("ang6App")
.controller("AirportsCtrl", function ($scope, Airports) {
$scope.airports = Airports;
});
I've learned to post everything through ng-model and input fields expect file uploads. There are a lot of questions on stackoverflow on adding upload buttons and how to store files using express and angular but they assume a lot for a novice. Also, I'm sure i've completely botched the grammar/nomenclature/syntax of angular, so if you could correct me, I wont make the mistakes again.