删除角度后的对象后,我的更新视图有问题。如果我单击删除一切正常,对象将从数据库中删除但仅在刷新页面时查看更新,但我想在删除项目后立即更新。敬请期待: 工厂:
userFactory.getDescription = function(){
return $http.get('/api/editProduct/')
}
的index.html
<div class="entry input-group" ng-repeat="item in newDescription track by $index">
<strong><input ng-disabled="editProduct.disabled" class="form-control" type="text" name="description" placeholder="Podaj opis kursu!!!" ng-model="newDescription[$index]" required></strong>
<span class="input-group-btn">
<a href="#" ng-click="editProduct.removeDescription(item)" class="btn btn-remove btn-danger">
<span class="glyphicon glyphicon-remove"></span>
</a>
</span>
控制器:
function getDescription() {
User.getDescription().then(function(data){
if(data.data.success) {
if(data.data.permission === 'admin' || data.data.permission === 'moderator') {
$scope.newDescription = data.data.product.description;
app.loading = false;
app.accessDenied = false;
if(data.data.permission === 'admin') {
app.editAccess = true;
app.deleteAccess = true;
} else if(data.data.permission === 'moderator') {
app.editAccess = true;
}
} else {
app.errorMsg = 'Insufficient Permissions';
app.loading = false;
}
} else {
app.errorMsg = data.data.message;
app.loading = false;
}
});
}
删除功能:
app.removeDescription = function(description){
var deleteDescription = {};
deleteDescription._id = app.currentProduct;
deleteDescription.description = description;
User.deleteDescription(deleteDescription).then(function(data){
if(data.data.success) {
getDescription()
} else {
app.showMoreError = data.data.message;
}
})
}
我确定问题出在getDescription()
函数中,但我无法看到问题