2016-11-23 44 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