已成功从数据库中删除数据,但未刷新AngularJS中的当前页面
Data deleted from DB successfully but not refreshed the current page in AngularJS
我尝试了几次删除数据,它成功地删除了数据,但没有显示更新的学生完整列表。。。。。
手动刷新网页后,它会显示更新的学生名单,请帮助我。
X.controller('StudentController', ['$scope', 'Student', 'Department', '$routeParams','$location', function ($scope, Student, Department, $routeParams,$location) {
$scope.v = 'test value';
$scope.profileid = $routeParams.Id;
console.log($scope.profileid);
////////////////RETRIVE ALL DATA FROM DB///////////////
function init() {
/////RETRIVE DATA FOR STUDENT/////////
$scope.student = { Name: '', Phone: '', Class_id: '', Department_id: '' };
$scope.students = [];
Student.get(function (response) {
console.log("List of Student");
$scope.students = response.Data;
console.log($scope.students);
});
///////RETRIVE DATA FOR DEPARTMENT////////////////////
$scope.depts = [];
Department.get(function (response) {
console.log("List of Dept");
$scope.depts = response.DeptData;
console.log($scope.depts);
});
};
////////////RETRIVE SPECIFIC DATA INTO DB/////////////
Student.get({ Id: $scope.profileid }, function (response) {
console.log("SPECIFIC DATA");
$scope.student = response.Data;
console.log($scope.students);
});
/////////////////////////////DELETE//////////////////
$scope.Stddelete = function (profileId) {
Student.delete({ Id: profileId });
console.log("DELETE");
init();
};
init();
}
]);
要更新DOM,需要从数组中splice
对象。
$scope.students.splice($index,1);
示例:
$scope.Stddelete = function (profileId,index) {
Student.delete({ Id: profileId });
$scope.students.splice(index,1);
console.log("DELETE");
init();
};
相关文章:
- 如何刷新AngularJs剑道网格
- 我怎样才能告诉AngularJS“刷新”
- AngularJS:点击选项卡刷新视图中的数据
- AngularJS-状态更改时停止自动刷新页面
- 使用angularJs中的数据库数据源刷新下拉列表
- 如何刷新吴重复与AngularJs
- AngularJS:当过滤值发生变化时刷新DOM
- AngularJS部分模板双向绑定&刷新困境
- angularjs在操作后没有刷新客户端
- laravel/angularjs JWT代币刷新
- AngularJS |刷新浏览器时,AngularJS模板会在安全上下文之前加载.如何阻止它
- AngularJS刷新对象中的属性
- $locationProvider html5mode导致“;无法获取“;刷新时出错-AngularJS Node应用程
- 如何使用AngularJS刷新HTML表
- AngularJS - 刷新包含新数据的列表
- 在使用angularjs刷新页面时,不应删除服务数据
- AngularJS刷新不'似乎不起作用
- AngularJS-刷新ng重复
- AngularJS刷新插值值
- Angularjs刷新和保存数据