Я изучаю angularJs, и я хочу создать базовое приложение crud с php и angularJs.
Я застрял в разделе удаления, пожалуйста, помогите мне.
вот мой код:
HTML
<ul> <li ng-repeat="data in data"> {{data.ID}} {{data.subject}} {{data.body}} <a ng-click="delete(data.id)" href="">Delete</a> </li> </ul>
JS
$scope.delete = function(){ var id = $scope.data.id; that = this; $http.get("delete.php?id=" + id) .success(function(data){ $scope.data.splice(that.$index, 1); }) }
Php
include('config.php'); mysql_select_db('ngdb'); $id = $_GET ['id']; $sql = "SELECT * FROM story"; $records = mysql_query($sql); if(isset($_GET ['id'])){ $id = $_GET ['id']; $delete = "DELETE FROM story WHERE id= '$id'"; $res = mysql_query($delete) or die ("FAILED" .mysql_error()); }
вinclude('config.php'); mysql_select_db('ngdb'); $id = $_GET ['id']; $sql = "SELECT * FROM story"; $records = mysql_query($sql); if(isset($_GET ['id'])){ $id = $_GET ['id']; $delete = "DELETE FROM story WHERE id= '$id'"; $res = mysql_query($delete) or die ("FAILED" .mysql_error()); }
где я ошибаюсь?