I am newbie to angularJS
. I have started learning with CRUD operation. I am getting a problem that when I delete
an entry then the page should reload
I have gone through $location
and $route
too. and implementing as follow :
config
app.config( function ( $locationProvider, $routeProvider ) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix = '!';
$routeProvider.when('/', {
templateUrl: '/views/index.html',
controller: 'MainCtrl'
});
$routeProvider.when('/this',{
templateUrl: '/views/about.html',
controller: 'MainCtrl'
});
});
and when action success then I am writing as :
$location.path('/this');
but when I do this then the url
changes from http://localhost/someapp
to http://this
but the page does not refresh. What should I do in this case please help me guys ?
Edit
:
Here is my deletion code
:
$scope.deletecode = function (id) {
name = '';
if (confirm("are you sure to Delete the name")) {
$http({
method: 'POST',
url: 'rohit.php',
data: {
"name": name,
"id": id,
"delete": "true"
},
}).
success(function (data, status, headers, config) {
alert("data deleted successfully");
$location.path('/this');
}).
error(function (data, status, headers, config) {
alert("Unable to load data.");
});
} else {
alert("Data deletion cancelled by user ... ");
}
};
On init I am getting the data from a php file :
$http({
method: 'GET',
url: 'test.php'
}).
success(function (data, status, headers, config) {
$scope.samples = data;
}).
error(function (data, status, headers, config) {
alert("Unable to load data.");
});
all the data is stored in $scope.samples
which returns two things user_id
and name