Angular.js programmatically setting a form field to dirty

后端 未结 11 2025
孤独总比滥情好
孤独总比滥情好 2020-12-02 10:57

I am programmatically updating some of the fields on my form with a value and I would like to set the field state to $dirty. Doing something like:

11条回答
  •  离开以前
    2020-12-02 11:19

    Made a jsFiddle just for you that solves this issue. simply set $dirty to true, but with a $timeout 0 so it runs after DOM was loaded.

    Find it here: JsFiddle

    $timeout(function () {
      $scope.form.uName.$dirty = true;
    }, 0);
    

提交回复
热议问题