{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/9459","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/9459/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/9459/comments","events_url":"https://api.github.com/repos/angular/angular/issues/9459/events","html_url":"https://github.com/angular/angular/issues/9459","id":161707788,"number":9459,"title":"[bug] RC.2 breaks @ViewChild to component thru forwardRef (recursive component structures)","user":{"login":"tycho01","id":3059397,"avatar_url":"https://avatars.githubusercontent.com/u/3059397?v=3","gravatar_id":"","url":"https://api.github.com/users/tycho01","html_url":"https://github.com/tycho01","followers_url":"https://api.github.com/users/tycho01/followers","following_url":"https://api.github.com/users/tycho01/following{/other_user}","gists_url":"https://api.github.com/users/tycho01/gists{/gist_id}","starred_url":"https://api.github.com/users/tycho01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tycho01/subscriptions","organizations_url":"https://api.github.com/users/tycho01/orgs","repos_url":"https://api.github.com/users/tycho01/repos","events_url":"https://api.github.com/users/tycho01/events{/privacy}","received_events_url":"https://api.github.com/users/tycho01/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular/labels/comp:%20core/view/compiler","name":"comp: core/view/compiler","color":"c7def8"},{"url":"https://api.github.com/repos/angular/angular/labels/type:%20bug","name":"type: bug","color":"EEEEEE"}],"state":"open","locked":false,"assignee":{"login":"tbosch","id":690815,"avatar_url":"https://avatars.githubusercontent.com/u/690815?v=3","gravatar_id":"","url":"https://api.github.com/users/tbosch","html_url":"https://github.com/tbosch","followers_url":"https://api.github.com/users/tbosch/followers","following_url":"https://api.github.com/users/tbosch/following{/other_user}","gists_url":"https://api.github.com/users/tbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbosch/subscriptions","organizations_url":"https://api.github.com/users/tbosch/orgs","repos_url":"https://api.github.com/users/tbosch/repos","events_url":"https://api.github.com/users/tbosch/events{/privacy}","received_events_url":"https://api.github.com/users/tbosch/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-06-22T15:06:02Z","updated_at":"2016-06-22T15:57:01Z","closed_at":null,"body":"After [this commit](https://github.com/angular/angular/commit/c3d2459) from RC2 (\"set fixed `@ViewChild` / `@ContentChild` right after the view is created\"), my `@ViewChild`s started breaking, erroring with:\r\n`Can't construct a query for the property <viewChildName> of <componentName> since the query selector wasn't defined`.\r\n\r\nSince I'm using recursive component structures, I have to use `forwardRef` to include the child components as directives into the host component. So what I have is like this:\r\n\r\n    @Component({\r\n      directives: [ forwardRef(() => ChildComp) ]\r\n    })\r\n    class HostComp {\r\n      @ViewChild(ChildComp) child: ChildComp;\r\n    }\r\n\r\nThe undefined selector here is the `ChildComp` argument of `@ViewChild(ChildComp)`. If this `forwardRef` is not yet resolved here at the moment it's interpreting the `ViewChild` since RC2, then I guess it makes sense that it's coming up with an undefined selector.\r\n\r\nI've yet to verify that with a minimal reproduction though. Plunker forthcoming -- I may need to await until my recent [PR](https://github.com/angular/angular/pull/8705) lands into the next RC. Anyway, posting this already in case anyone else has come across this error as well.\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/227790180","html_url":"https://github.com/angular/angular/issues/9459#issuecomment-227790180","issue_url":"https://api.github.com/repos/angular/angular/issues/9459","id":227790180,"user":{"login":"vicb","id":248818,"avatar_url":"https://avatars.githubusercontent.com/u/248818?v=3","gravatar_id":"","url":"https://api.github.com/users/vicb","html_url":"https://github.com/vicb","followers_url":"https://api.github.com/users/vicb/followers","following_url":"https://api.github.com/users/vicb/following{/other_user}","gists_url":"https://api.github.com/users/vicb/gists{/gist_id}","starred_url":"https://api.github.com/users/vicb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vicb/subscriptions","organizations_url":"https://api.github.com/users/vicb/orgs","repos_url":"https://api.github.com/users/vicb/repos","events_url":"https://api.github.com/users/vicb/events{/privacy}","received_events_url":"https://api.github.com/users/vicb/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T15:57:01Z","updated_at":"2016-06-22T15:57:01Z","body":"Would that work ?\r\n\r\n```\r\nclass HostComp {\r\n  @ViewChild(forwardRef(() => ChildComp)) child: ChildComp;\r\n```"}}
{"actor":{"display_login":"vicb"}}