Is there a way in angularJS to write data to file in local folder? I managed to get data from the file and now i want to write something.
I get data from data.json
, but order.txt
is 404 (Not Found)
or ERR_CONNECTION_REFUSED
.
angular.module("sportsStore")
.constant("dataUrl", "data.json")
.constant("orderUrl", "order.txt")
.controller("sportsStoreCtrl", function ($scope, $http, $location,
dataUrl, orderUrl, cart) {
$scope.data = {
};
$http.get(dataUrl)
.success(function (data) {
$scope.data.products = data;
})
.error(function (error) {
$scope.data.error = error;
});
$scope.sendOrder = function (shippingDetails) {
var order = angular.copy(shippingDetails)
order.products = cart.getProducts();
$http.post(orderUrl, order)
.success(function (data) {
$scope.data.orderId = data.id;
})
.error(function (error) {
$scope.data.orderError = error;
});
}
});