Detect unsaved changes and alert user using angularjs

前端 未结 7 1685
执念已碎
执念已碎 2020-11-29 18:50

Below is the code so far

    


    

        
7条回答
  •  情话喂你
    2020-11-29 19:53

    Something like this should do it:

    
    
    
        
        
    
    
        
    myModel.text:

    myModel.text = {{myModel.text}}

    $pristine = {{myForm.$pristine}}

    $dirty = {{myForm.$dirty}}

    Note that the listener for $locationChangeStart isn't triggered in this example since AngularJS doesn't handle any routing in such a simple example, but it should work in an actual Angular application.

提交回复
热议问题