나는 angularJS
에 초보자입니다. CRUD 작업으로 학습을 시작했습니다. 나는 다음 항목을 delete
때 페이지가 reload
angularJs를 사용하는 페이지 새로 고침
내가 너무 $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');
을하지만 난 http://localhost/someapp
에서 http://this
하지만 페이지로 다음 url
변경이 작업을 수행 할 때 새로 고침하지 않습니다. 이 경우 어떻게해야합니까? 제발 도와주세요.
Edit
: 여기
deletion code
: 모든 데이터가
$scope.samples
에 저장됩니다
$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.");
});
반환 : 나는 PHP 파일에서 데이터를 얻고 초기화에
$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 ... ");
}
};
두 가지 user_id
및 name
실제로 페이지를 새로 고칠 지 확신하지 않습니다. 항목을 삭제하면 올바르게 완료되면 페이지를 새로 고칠 필요없이보기가 업데이트됩니다. – xbonez
보기가 업데이트되지 않습니다.보기를 어떻게 업데이트 할 수 있습니까? 삭제 기능을 게시하고 있습니다. –
내 코드가 업데이트되었습니다. –