{"action":"opened","number":9097,"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/9097","id":73116860,"html_url":"https://github.com/angular/angular/pull/9097","diff_url":"https://github.com/angular/angular/pull/9097.diff","patch_url":"https://github.com/angular/angular/pull/9097.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/9097","number":9097,"state":"open","locked":false,"title":"fix(forms): update value and validity when controls are added","user":{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false},"body":"Currently, when adding or removing controls from a ControlGroup programmatically, the group value and validity state are not updated for you.   It's necessary to call `updateValueAndValidity()` manually:\r\n\r\n```ts\r\nclass MyComp {\r\n   constructor() {\r\n      this.form = new ControlGroup({\r\n         first: new Control('1')\r\n      })\r\n   }\r\n\r\n  add() {\r\n     this.form.addControl('second', new Control('2'));    // this.form.value == {first: '1'}\r\n     this.form.updateValueAndValidity();    // this.form.value == {first: '1', second: '2'}\r\n  \r\n  }\r\n}\r\n```\r\n\r\nThis can be misleading, especially since the corresponding method in ControlArrays (`push()`) *does* update value/validity for you.\r\n\r\nNow, when you call `addControl` or `removeControl` on a ControlGroup, `updateValueAndValidity` is called automatically.    The old version of `addControl` that simply registers it with the group's control list is still available under `registerControl()`.\r\n\r\n```ts\r\nclass MyComp {\r\n   constructor() {\r\n      this.form = new ControlGroup({\r\n         first: new Control('1')\r\n      })\r\n   }\r\n\r\n  add() {\r\n    // this.form.value == {first: '1'}\r\n     this.form.addControl('second', new Control('2'));  // this.form.value == {first: '1', second: '2'}\r\n  }\r\n}\r\n```","created_at":"2016-06-08T20:43:25Z","updated_at":"2016-06-08T20:43:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/9097/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/9097/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/9097/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/4ba347cea17a46c408cfbc1a3926be57bbf7baab","head":{"label":"kara:forms","ref":"forms","sha":"4ba347cea17a46c408cfbc1a3926be57bbf7baab","user":{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false},"repo":{"id":30559627,"name":"angular","full_name":"kara/angular","owner":{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kara/angular","description":"","fork":true,"url":"https://api.github.com/repos/kara/angular","forks_url":"https://api.github.com/repos/kara/angular/forks","keys_url":"https://api.github.com/repos/kara/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kara/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kara/angular/teams","hooks_url":"https://api.github.com/repos/kara/angular/hooks","issue_events_url":"https://api.github.com/repos/kara/angular/issues/events{/number}","events_url":"https://api.github.com/repos/kara/angular/events","assignees_url":"https://api.github.com/repos/kara/angular/assignees{/user}","branches_url":"https://api.github.com/repos/kara/angular/branches{/branch}","tags_url":"https://api.github.com/repos/kara/angular/tags","blobs_url":"https://api.github.com/repos/kara/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kara/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kara/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/kara/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kara/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/kara/angular/languages","stargazers_url":"https://api.github.com/repos/kara/angular/stargazers","contributors_url":"https://api.github.com/repos/kara/angular/contributors","subscribers_url":"https://api.github.com/repos/kara/angular/subscribers","subscription_url":"https://api.github.com/repos/kara/angular/subscription","commits_url":"https://api.github.com/repos/kara/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/kara/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/kara/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/kara/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/kara/angular/contents/{+path}","compare_url":"https://api.github.com/repos/kara/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kara/angular/merges","archive_url":"https://api.github.com/repos/kara/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kara/angular/downloads","issues_url":"https://api.github.com/repos/kara/angular/issues{/number}","pulls_url":"https://api.github.com/repos/kara/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/kara/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/kara/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kara/angular/labels{/name}","releases_url":"https://api.github.com/repos/kara/angular/releases{/id}","deployments_url":"https://api.github.com/repos/kara/angular/deployments","created_at":"2015-02-09T21:32:22Z","updated_at":"2016-01-24T16:23:07Z","pushed_at":"2016-06-08T20:31:16Z","git_url":"git://github.com/kara/angular.git","ssh_url":"git@github.com:kara/angular.git","clone_url":"https://github.com/kara/angular.git","svn_url":"https://github.com/kara/angular","homepage":null,"size":29449,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"29c2dcff616a8a8505b499d1efd4a57a0409bed5","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","deployments_url":"https://api.github.com/repos/angular/angular/deployments","created_at":"2014-09-18T16:12:01Z","updated_at":"2016-06-08T20:29:55Z","pushed_at":"2016-06-08T20:43:25Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":"https://angular.io","size":611096,"stargazers_count":12673,"watchers_count":12673,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3286,"mirror_url":null,"open_issues_count":1397,"forks":3286,"open_issues":1397,"watchers":12673,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/9097"},"html":{"href":"https://github.com/angular/angular/pull/9097"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/9097"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/9097/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/9097/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/9097/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/4ba347cea17a46c408cfbc1a3926be57bbf7baab"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":43,"deletions":7,"changed_files":3}}
{"actor":{"display_login":"kara"}}