我是新手angularJS
。我已经开始学习 CRUD 操作。我遇到一个问题,当我delete
输入时,页面应该reload
$location
我也经历$route
过。并实施如下:
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'
});
});
当行动成功时,我写成:
$location.path('/this');
但是当我这样做时,url
从http://localhost/someapp
到更改http://this
但页面不会刷新。在这种情况下我该怎么办,请帮帮我?
Edit
:
这是我的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 ... ");
}
};
在初始化时,我从 php 文件中获取数据:
$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.");
});
所有数据都存储在$scope.samples
其中返回两件事user_id
和name