{"action":"created","issue":{"url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/637","repository_url":"https://api.github.com/repos/json-schema-form/angular-schema-form","labels_url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/637/labels{/name}","comments_url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/637/comments","events_url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/637/events","html_url":"https://github.com/json-schema-form/angular-schema-form/issues/637","id":132495707,"number":637,"title":"Injecting error deletes value on change","user":{"login":"Zundrium","id":4927792,"avatar_url":"https://avatars.githubusercontent.com/u/4927792?v=3","gravatar_id":"","url":"https://api.github.com/users/Zundrium","html_url":"https://github.com/Zundrium","followers_url":"https://api.github.com/users/Zundrium/followers","following_url":"https://api.github.com/users/Zundrium/following{/other_user}","gists_url":"https://api.github.com/users/Zundrium/gists{/gist_id}","starred_url":"https://api.github.com/users/Zundrium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zundrium/subscriptions","organizations_url":"https://api.github.com/users/Zundrium/orgs","repos_url":"https://api.github.com/users/Zundrium/repos","events_url":"https://api.github.com/users/Zundrium/events{/privacy}","received_events_url":"https://api.github.com/users/Zundrium/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/json-schema-form/angular-schema-form/labels/merged%20into%20development","name":"merged into development","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-09T18:33:32Z","updated_at":"2016-03-25T10:58:49Z","closed_at":"2016-03-09T10:33:01Z","body":"Whenever I use a `$broadcast` with `schemaForm.error.`:\r\n`$scope.$broadcast('schemaForm.error.name','usernameAlreadyTaken','The username is already taken')`\r\n\r\nThe key `name` in the `$scope.model` object becomes undefined when I **change** the value in the input.\r\n\r\nHowever, when I switch the error off with:\r\n`$scope.$broadcast('schemaForm.error.name','usernameAlreadyTaken',true)`\r\n\r\nThe error becomes a 'required' error and when I type and change the value in the input, the value is bound again in `$scope.model`.\r\n\r\nIs this a bug or am I using the `$broadcast` wrong?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/comments/201239892","html_url":"https://github.com/json-schema-form/angular-schema-form/issues/637#issuecomment-201239892","issue_url":"https://api.github.com/repos/json-schema-form/angular-schema-form/issues/637","id":201239892,"user":{"login":"LeonardoGentile","id":412061,"avatar_url":"https://avatars.githubusercontent.com/u/412061?v=3","gravatar_id":"","url":"https://api.github.com/users/LeonardoGentile","html_url":"https://github.com/LeonardoGentile","followers_url":"https://api.github.com/users/LeonardoGentile/followers","following_url":"https://api.github.com/users/LeonardoGentile/following{/other_user}","gists_url":"https://api.github.com/users/LeonardoGentile/gists{/gist_id}","starred_url":"https://api.github.com/users/LeonardoGentile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeonardoGentile/subscriptions","organizations_url":"https://api.github.com/users/LeonardoGentile/orgs","repos_url":"https://api.github.com/users/LeonardoGentile/repos","events_url":"https://api.github.com/users/LeonardoGentile/events{/privacy}","received_events_url":"https://api.github.com/users/LeonardoGentile/received_events","type":"User","site_admin":false},"created_at":"2016-03-25T10:58:49Z","updated_at":"2016-03-25T10:58:49Z","body":"It doesn't seems this is 100% fixed.\r\nUsing the development branch, this is what I do:\r\n\r\n```\r\nif (form.$valid) {\r\n    var data = angular.copy($scope.model);\r\n    $http.post(path, data)\r\n        .then(function(response) {\r\n            console.log(response.data);\r\n        })\r\n        .catch(function(responseError) {\r\n            $scope.$broadcast('schemaForm.error.title', 'rejected', 'The username is already taken');\r\n\r\n            var unregister = $scope.$watch('model1.title', function(value, oldValue) {\r\n                if (value != oldValue) { // from now on $scope.model.title will always been undefined\r\n                    unregister();\r\n                    // Reset the error\r\n                    $scope.$broadcast('schemaForm.error.title', 'rejected', true);\r\n                }\r\n\r\n            });\r\n        });\r\n}\r\n```\r\nI'm watching changes in the model field that caused the async validation, and if the value has changed just reset the async validation.\r\nThe problem is that (similarly to  @Zundrium) after setting the field 'title' as invalid the `$scope.model.title` property will always be `undefined`"}}