{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/12277","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/12277/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/12277/comments","events_url":"https://api.github.com/repos/angular/angular/issues/12277/events","html_url":"https://github.com/angular/angular/issues/12277","id":182830226,"number":12277,"title":"Angular 2 Nested Form and Validation","user":{"login":"deepikabhandari2592","id":22395139,"avatar_url":"https://avatars.githubusercontent.com/u/22395139?v=3","gravatar_id":"","url":"https://api.github.com/users/deepikabhandari2592","html_url":"https://github.com/deepikabhandari2592","followers_url":"https://api.github.com/users/deepikabhandari2592/followers","following_url":"https://api.github.com/users/deepikabhandari2592/following{/other_user}","gists_url":"https://api.github.com/users/deepikabhandari2592/gists{/gist_id}","starred_url":"https://api.github.com/users/deepikabhandari2592/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepikabhandari2592/subscriptions","organizations_url":"https://api.github.com/users/deepikabhandari2592/orgs","repos_url":"https://api.github.com/users/deepikabhandari2592/repos","events_url":"https://api.github.com/users/deepikabhandari2592/events{/privacy}","received_events_url":"https://api.github.com/users/deepikabhandari2592/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-13T15:57:37Z","updated_at":"2016-10-13T16:36:34Z","closed_at":null,"body":"First of all I just begin with Angular 2 and I'm trying to build a nested form and validate it.I had posted this question on stackoverflow but dint got any reply so raising this question as a bug .Please revert with the solution as soon as possible .Thank you\r\nHere's part of my ts file:\r\n\r\nngOnInit() {\r\n  this.myForm = this.formBuilder.group({\r\n    projects: this.formBuilder.array([\r\n      this.initProjects()\r\n    ])\r\n  });\r\n}\r\n\r\ninitProjects(): any {\r\n  return this.formBuilder.group({\r\n    name: ['', [Validators.required, Validators.minLength(3)]],\r\n    some_array: this.formBuilder.array([\r\n      this.formBuilder.group({\r\n        name: ['', Validators.required],\r\n        attr: ['', Validators.required],\r\n        some_id: [1, Validators.required]\r\n      })\r\n    ])\r\n  });\r\n}\r\n\r\naddProject(): void {\r\n  const control = < FormArray > this.myForm.controls['projects'];\r\n  control.push(this.initProjects());\r\n}\r\n\r\n\r\n\r\nView:\r\n\r\n<form [formGroup]=\"myForm\" novalidate (ngSubmit)=\"onSubmit(myForm)\">\r\n  <div formArrayName=\"projects\">\r\n    <div *ngFor=\"let project of myForm.controls.projects.controls; let i = index\">\r\n      <div [formGroupName]=\"i\">\r\n        <md-input placeholder=\"Name\" formControlName=\"name\"></md-input>\r\n      </div>\r\n      <div *ngFor=\"let some_obj of project.controls.some_array.controls; let x = index\">\r\n        <div [formGroupName]=\"x\">\r\n          <div>\r\n            <md-input placeholder=\"Nome\" formControlName=\"controls.some_array.controls.name\"></md-input>\r\n            <small *ngIf=\"!some_obj.controls.name.valid\">\r\n                    Nome é requerido\r\n                  </small>\r\n          </div>\r\n          <md-input type=\"number\" placeholder=\"Cost\" formControlName=\"controls.some_array.controls.attr\" required></md-input>\r\n        </div>\r\n      </div>\r\n    </div>\r\n  </div>\r\n  <button type=\"submit\" md-raised-button color=\"primary\" [disabled]=\"!myForm.valid\">Submit</button>\r\n</form>\r\n<pre>form value: <br>{{myForm.value | json}}</pre>\r\n\r\n\r\n\r\nform value: \r\n{\r\n  \"projects\": [\r\n    {\r\n      \"name\": \"\",\r\n      \"some_array\": [\r\n        {\r\n          \"name\": \"\",\r\n          \"attr\": \"\",\r\n          \"some_id\": 1\r\n        }\r\n      ]\r\n    },\r\n    {\r\n      \"name\": \"\",\r\n      \"some_array\": [\r\n        {\r\n          \"name\": \"\",\r\n          \"attr\": \"\",\r\n          \"some_id\": 1\r\n        }\r\n      ]\r\n    }\r\n  ]\r\n}\r\n\r\n\r\n\r\nWell, as you can see I have some arrays called projects, with 1 array inside each one.\r\n\r\nSo the problem is that I'm not able to validate each control of some_array array.\r\n\r\nActually I'm getting the following error:\r\n\r\nORIGINAL EXCEPTION: Cannot find control with path: 'projects -> 0 -> controls.some_array.controls.name\r\nPS: I already tried to put it in a div, as below:\r\n\r\n<div formArrayName=\"some_array\">\r\n\r\n\r\nBut I also got an error:\r\n\r\nCannot find control with path: 'projects -> some_array'\r\nThanks in advance. Any help would be appreciated."},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/253567510","html_url":"https://github.com/angular/angular/issues/12277#issuecomment-253567510","issue_url":"https://api.github.com/repos/angular/angular/issues/12277","id":253567510,"user":{"login":"deepikabhandari2592","id":22395139,"avatar_url":"https://avatars.githubusercontent.com/u/22395139?v=3","gravatar_id":"","url":"https://api.github.com/users/deepikabhandari2592","html_url":"https://github.com/deepikabhandari2592","followers_url":"https://api.github.com/users/deepikabhandari2592/followers","following_url":"https://api.github.com/users/deepikabhandari2592/following{/other_user}","gists_url":"https://api.github.com/users/deepikabhandari2592/gists{/gist_id}","starred_url":"https://api.github.com/users/deepikabhandari2592/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepikabhandari2592/subscriptions","organizations_url":"https://api.github.com/users/deepikabhandari2592/orgs","repos_url":"https://api.github.com/users/deepikabhandari2592/repos","events_url":"https://api.github.com/users/deepikabhandari2592/events{/privacy}","received_events_url":"https://api.github.com/users/deepikabhandari2592/received_events","type":"User","site_admin":false},"created_at":"2016-10-13T16:36:34Z","updated_at":"2016-10-13T16:36:34Z","body":"@manklu : I think my question is self explanatory ."}}
{"actor":{"display_login":"deepikabhandari2592"}}