{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/ui-utils/issues/352","labels_url":"https://api.github.com/repos/angular-ui/ui-utils/issues/352/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/ui-utils/issues/352/comments","events_url":"https://api.github.com/repos/angular-ui/ui-utils/issues/352/events","html_url":"https://github.com/angular-ui/ui-utils/issues/352","id":55948814,"number":352,"title":"UI-Mask remains $dirty when used inside of ng-repeat and form.$setPristine is called.","user":{"login":"NateRedding","id":3064840,"avatar_url":"https://avatars.githubusercontent.com/u/3064840?v=3","gravatar_id":"","url":"https://api.github.com/users/NateRedding","html_url":"https://github.com/NateRedding","followers_url":"https://api.github.com/users/NateRedding/followers","following_url":"https://api.github.com/users/NateRedding/following{/other_user}","gists_url":"https://api.github.com/users/NateRedding/gists{/gist_id}","starred_url":"https://api.github.com/users/NateRedding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NateRedding/subscriptions","organizations_url":"https://api.github.com/users/NateRedding/orgs","repos_url":"https://api.github.com/users/NateRedding/repos","events_url":"https://api.github.com/users/NateRedding/events{/privacy}","received_events_url":"https://api.github.com/users/NateRedding/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular-ui/ui-utils/labels/ui-mask","name":"ui-mask","color":"000000"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-29T20:00:59Z","updated_at":"2015-07-01T07:59:47Z","closed_at":"2015-07-01T07:59:47Z","body":"I created a [Plunker](http://run.plnkr.co/plunks/PKA5Vv61Zl3KdSwahpFj/). Change the field and hit 'Reset'. You will see the form and field stay dirty. Clicking a second time sets everything to $pristine properly. Interestingly enough, you don't actually have to change the field - just click Reset and the field and form will be marked dirty without even doing anything!\r\n\r\nng-repeat seems to have some weird behavior where it creates a new element temporarily when $setPristine is called. This causes ui-mask's initializeElement() to be called, which tries to avoid dirtying the form by setting $viewValue directly rather than using $setViewValue, but the form still seems to be dirty afterwards.\r\n\r\n              function initializeElement(){\r\n                ...\r\n                iElement.val(viewValue);\r\n                controller.$viewValue = viewValue;  // THIS LINE SEEMS TO DIRTY THE FORM\r\n                // Not using $setViewValue so we don't clobber the model value and dirty the form\r\n                // without any kind of user interaction.\r\n              }\r\n\r\nCommenting out the line marked in the code snippet above seems to fix the part of the problem with ng-repeat (the first click doesn't dirty the form anymore),  but it doesn't seem like a good fix. And, there is the problem of the form still being dirty after the first call to $setPristine() anyways. Even using the field outside of an ng-repeat seems to have a similar problem with $dirty being set after changing the field and then calling $setPristine(). It does not have the problem when not changing the field, however.\r\n\r\nNote: This uses the 0.2.1 version of ui-mask modified slightly with the fix in #350 as we want clearOnBlur working properly.\r\n\r\nFYI, for some reason I couldn't get the plunker to behave exactly the same as the code in my app... in my app, commenting out the above line seems to fix the problem entirely (still probably not a correct fix though)."},"comment":{"url":"https://api.github.com/repos/angular-ui/ui-utils/issues/comments/117517274","html_url":"https://github.com/angular-ui/ui-utils/issues/352#issuecomment-117517274","issue_url":"https://api.github.com/repos/angular-ui/ui-utils/issues/352","id":117517274,"user":{"login":"PowerKiKi","id":72603,"avatar_url":"https://avatars.githubusercontent.com/u/72603?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerKiKi","html_url":"https://github.com/PowerKiKi","followers_url":"https://api.github.com/users/PowerKiKi/followers","following_url":"https://api.github.com/users/PowerKiKi/following{/other_user}","gists_url":"https://api.github.com/users/PowerKiKi/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerKiKi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerKiKi/subscriptions","organizations_url":"https://api.github.com/users/PowerKiKi/orgs","repos_url":"https://api.github.com/users/PowerKiKi/repos","events_url":"https://api.github.com/users/PowerKiKi/events{/privacy}","received_events_url":"https://api.github.com/users/PowerKiKi/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T07:59:47Z","updated_at":"2015-07-01T07:59:47Z","body":"UI.Utils modules was split in individuals repositories. If still valid, please consider re-submitting on its dedicated repository: https://github.com/angular-ui/ui-mask\r\n\r\nSee the [README for details](https://github.com/angular-ui/ui-utils#readme).\r\n"}}