I used the following codes for creating a form submit with angular $http.
HTML (in the controller div
):
<input type="text" name="job" ng-model="item.job">
<button type="submit" ng-click="post()">Add</button>
JS (in the app controller):
$scope.post = function() {
$scope.item.done = "";
$http.post("data/todo.json", $scope.item)
.success(function (data) {
console.log("OK");
})
.error(function () {
console.log("Sorry");
});
};
After run, it seems everything is OK and success message comes to console, but the todo.json
file doesn't change!
Any Idea?
Aucun commentaire:
Enregistrer un commentaire