$ SetValidity form will revert to true does not work

I have set up a form to validate for the OnBlur event on the server side. Server side validation works fine and returns errors as expected. However, once I've set a value for the false

field, setting it back to true

doesn't remove the $ error messages. Is $ setValidity true to remove errors from the form?

This is the controller:

angular.module('artists').controller('ArtistsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Artists',
  function($scope, $stateParams, $location, Authentication, Artists) {
    $scope.authentication = Authentication;

    $scope.processForm = function(val){

        var artist = new Artists({
            name: $scope.artistForm.name.$viewValue,
            quote: $scope.artistForm.quote.$viewValue
        artist.$save(function(response) {
        }, function(errorResponse) {
          if(val in errorResponse.data){




source to share

1 answer

In my case, the field is back to normal, but when I edit it. This is because the $ area is loaded from another controller and is not applied. Therefore you need to use$apply



Here's the docs: https://docs.angularjs.org/api/ng/type/ $ rootScope.Scope



All Articles