2016-11-23 38 views
0

我正在尝试做一个窗体的更新和所有工作正常,但更新完成后模式不能正确关闭。我的意思是模态消失了,但屏幕仍然黑暗,模态仍然存在,我不能点击其他任何东西。如何让页面刷新并使模式正常关闭?无法在angularjs中提交后关闭模式

我的代码所示:

$scope.updateStudentParticulars = function(item) { 
      var currentDate = $filter('date')(new Date(), 'dd/MM/yyyy'); //for lastchangepassword field 
      $scope.EditStudentForm = false; 

      //alert(item.User_Key + " USER KEY") 

      const rootRef = firebase.database().ref(); 

      //zoom in to users table 
      const ref = rootRef.child('Users'); 

      ref.child(item.User_Key).update({ 
       name: item.Student_Name, 
       email: item.Student_Email, 
       role: "student", 
       accountStatus: "Activated", 
       yearJoined: item.Year_Joined, 
       password: item.Password, 
       passwordChangedDate: currentDate, 
       gpa: 0.00, 
       profile: { 
        address: item.Address, 
        citizenship: item.Citizenship, 
        gender: item.Gender, 
        nok: item.Nok, 
        nokPhone: item.Nok_Phone, 
        phone: item.Phone 
       } 

      }); 
      alert("Update Successful !") 
      $route.reload(); 

     } 

模态代码在HTML文件中声明:

<div id="editModal" class="modal fade" role="dialog"> 
     <div class="modal-dialog"> 

      <!-- Modal content--> 
      <div class="modal-content"> 
       <div class="modal-header"> 
        <h4 class="modal-title">Edit Student Particulars</h4> 
       </div> 
       <div class="modal-body"> 
        <div ng-include src="'templates/editStudentForm.html'"></div> 
       </div> 
       <div class="modal-footer"> 
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
       </div> 
      </div> 

     </div> 
    </div> 
+2

但是......哪里是你情态码? – trichetriche

+0

它在另一个html文件中,我已编辑的问题,并在代码中添加 – purplewind

+0

这很好,但现在,你在哪里JS模式代码? – trichetriche

回答

0

看起来你正在使用的引导模态。一旦你包括引导JS代码,您可以拨打:

$('#editModal').modal('hide'); 

http://getbootstrap.com/javascript/

+0

嗨,我添加了代码,但即使提交,背景仍然存在。任何想法如何彻底摧毁背景? – purplewind