How to hide modal window on $route.reload (using angularjs-ui)? -
i have form in modal window adds data database. upon successful addition, calling $route.reload() function refresh underlying page, however, modal window still shown.
$scope.add = function() { $http.post('/api/contact', $scope.form). success(function(data) { $scope.showmodal = false; $route.reload(); }); };
the modal standard angularjs-ui modal:
<div modal="showmodal" close="close()" options="opts"> etc </div>
i tried add $scope.showmodal = false;
@ beginning of controller didn't either.
here's code in plnkr:
http://plnkr.co/edit/xz6gjrtbisvcem0gnlx6?p=preview
note aware if comment out $route.reload()
option items in list updated, in app writing things database i'd need $route.reload need re-query db.
you need timeout before applying $route.reload() because that's trying fire off before browser has time update view. works: http://plnkr.co/edit/e7oraq?p=preview
also, unless you're dealing non-angular stuff, there isn't reason reload write db. should able re-query within controller.
Comments
Post a Comment