Nodejs Angularjs Mongoose Internet Explorer 11兼容性

我正在开发和pipe理面板使用Angularjs作为前端框架,在后端的Nodejs和Mongoose的mongoDB模型。

pipe理员angular色可以删除所有用户,如下所示:

AdminPanel.html(在此页面中,我正在显示网站pipe理员可以删除的用户列表)

<!-- Header --> <div ng:include="'/views/common/header.html'"></div> <!-- End Header --> <div data-ng-init='initial()'> <br> <br> <span style="float:right"><b>Bienvenue {{admin.local.nom }} !</b> </span> <br> <div style="float:right"> <a href="/logout"> <i class="fa fa-unlock-alt"></i> Se déconnecter </a> </div> <br> <span class="label label-primary">{{listeProfils.length}}</span> <div class="row"> <div class="col-md-4 text-center"> <span>Mes comptes :</span> <span class="label label-primary">{{comptes.length}}</span></div> <div class="col-md-4"> <div class="input-group"> <input type="text" class="form-control input-sm" ng-model="query"> <span class="input-group-addon"> <span class="glyphicon glyphicon-search"></span> </span> </div> </div> <div class="col-md-4 text-center"> </div> </div> <br> <table class="table table-hover table-bordered table-condensed"> <thead> <tr> <th ng-repeat="header in headers" class="centering">{{header}}</th> </tr> </thead> <tbody> <tr ng-repeat="compte in comptes | filter : query"> <td>{{ compte.local.nom }}</td> <td>{{ compte.local.prenom }}</td> <td>{{ compte.local.email }}</td> <td style="width:150px; text-align:center"><button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal" ng-click="preSupprimer(compte)"><span class="glyphicon glyphicon-remove-circle"></span></button></td> </tr> </tbody> </table> </div> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="myModalLabel">Suppression</h4> </div> <div class="modal-body"> Le compte sélectionné va être définitivement supprimé du système. Confirmez-vous cette suppression? </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button> <button type="button" class="btn btn-primary" ng-click="deleteAccount()" data-dismiss="modal">Confirmer suppression</button> </div> </div> </div> </div> <!-- Footer --> <div ng:include="'/views/common/footer.html'"></div> <!-- End Footer --> <div class="loader" ng-show="loader"></div> when the admin clicks on the button to delete the user account from the database, a bootstrap Modal fires and tells the Administrator wether to confirm deletion or not. 

点击确认后,从adminPanel控制器触发deleteAccount()方法,定义如下:

AdminPanel.js:

  'use strict'; angular.module('App').controller('AdminPanelCtrl', function($scope, $http, $location, configuration) { $scope.headers = ['Nom', 'Prenom', 'Email', 'Action']; $scope.loader = false; $scope.listAccounts = function() { $http.get(configuration.URL_REQUEST + '/allAccounts') .success(function(data) { $scope.comptes = data; }); }; $scope.initial = function() { $http.get(configuration.URL_REQUEST + '/adminService').success(function(data, status) { $scope.admin = data; }).error(function() { $location.path('/logout'); }); $scope.listAccounts(); }; $scope.deleteAccount = function() { $scope.loader = true; $http.post(configuration.URL_REQUEST + '/deleteAccounts', $scope.compteAsupprimer) .success(function(data) { console.log('deleted' + data); $scope.listAccounts(); $scope.loader = false; }); }; $scope.preSupprimer = function(account) { $scope.compteAsupprimer = account; } }); 

我的dao文件如下:

  /* Delete userAccounts */ exports.supprimer = function(req, res) { var userAccount = new UserAccount(req.body); UserAccount.findById(userAccount._id, function(err, item) { if (err) { res.send({ 'result': 'error' }); } else { UserAccount.remove(item, function() { res.send({ 'result': 'error' }); }); } }); }; 

并与route.js路线

所以,当我点击删除帐户buttonON IE11时,问题开始,该帐户从mongoDB数据库中删除,但显示在网格中。 当我刷新页面的帐户仍然在网格中。 但是,当我closuresIE11,重新打开url,它不显示,并给我我想要的结果。

所以我的问题是:我怎么能执行这个动作,而不让用户closures他的浏览器,并重新打开它,删除后直接刷新帐户列表。 Firefox,Chrome和safari支持这个function,是否有.send()函数的问题,我已经试过json()和jsonp()..

任何反馈?

Solutions Collecting From Web of "Nodejs Angularjs Mongoose Internet Explorer 11兼容性"

这听起来像一个jQuery或Ajaxcaching问题。 如果你使用jQuery,你可以在你的项目开始时用这个打开caching清除代码:

 $.ajaxSetup({ cache: false }); 

我不知道对应的设置将是什么angular度,但我知道,我有过去IE浏览器cachingAjax请求的麻烦。

我已经解决了Angularjs这样的问题:

 myModule.config(['$httpProvider', function($httpProvider) { //initialize get if not there if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } //disable IE ajax request caching $httpProvider.defaults.headers.get['If-Modified-Since'] = '0'; }]);