Prevent input from setting form $dirty angularjs

前端 未结 7 1438
天涯浪人
天涯浪人 2021-02-07 05:37

I have an ng form on a page. Inside the form I have several controls which need to display a save dialog when the form is dirty, ie form.$dirty = true. However there are some na

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 06:16

    Angular only sets the form dirty if the control is pristine. So the trick here is to set $pristine on the control to false. You can do it in a timeout in the controller.

    see: http://plnkr.co/edit/by3qTM

提交回复
热议问题