{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/19316","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/19316/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/19316/comments","events_url":"https://api.github.com/repos/angular/angular/issues/19316/events","html_url":"https://github.com/angular/angular/issues/19316","id":259504219,"number":19316,"title":"Templateref inside ngIf cannot be accessed from outside","user":{"login":"peterreisz","id":11595433,"avatar_url":"https://avatars1.githubusercontent.com/u/11595433?v=4","gravatar_id":"","url":"https://api.github.com/users/peterreisz","html_url":"https://github.com/peterreisz","followers_url":"https://api.github.com/users/peterreisz/followers","following_url":"https://api.github.com/users/peterreisz/following{/other_user}","gists_url":"https://api.github.com/users/peterreisz/gists{/gist_id}","starred_url":"https://api.github.com/users/peterreisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterreisz/subscriptions","organizations_url":"https://api.github.com/users/peterreisz/orgs","repos_url":"https://api.github.com/users/peterreisz/repos","events_url":"https://api.github.com/users/peterreisz/events{/privacy}","received_events_url":"https://api.github.com/users/peterreisz/received_events","type":"User","site_admin":false},"labels":[{"id":375501288,"url":"https://api.github.com/repos/angular/angular/labels/comp:%20core%20&%20compiler","name":"comp: core & compiler","color":"c7def8","default":false},{"id":375497956,"url":"https://api.github.com/repos/angular/angular/labels/severity2:%20inconvenient","name":"severity2: inconvenient","color":"0052cc","default":false},{"id":130606843,"url":"https://api.github.com/repos/angular/angular/labels/type:%20bug/fix","name":"type: bug/fix","color":"EEEEEE","default":false},{"id":375496419,"url":"https://api.github.com/repos/angular/angular/labels/workaround1:%20obvious","name":"workaround1: obvious","color":"d4c5f9","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-21T13:53:16Z","updated_at":"2018-03-09T18:21:50Z","closed_at":"2018-02-06T23:56:15Z","author_association":"NONE","body":"<!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n<!-- Check one of the following options with \"x\" -->\r\n<pre><code>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[X] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n</code></pre>\r\n\r\n## Current behavior\r\n<!-- Describe how the issue manifests. -->\r\n\r\nTemplateref inside ngIf cannot be accessed from outside:\r\n\r\n```ts\r\nexport class App {\r\n  log(ref) {\r\n    console.log(ref);\r\n  }\r\n}\r\n```\r\n\r\n```html\r\n<button (click)=\"visible=true\">show</button>\r\n<button (click)=\"visible=false\">hide</button>\r\n<button (click)=\"log(ref)\">log</button> <!-- Does not work: logs undefined -->\r\n<div *ngIf=\"visible\">\r\n  <button (click)=\"log(ref)\">log</button> <!-- It works: logs tag-->\r\n  <span #ref>asdfasdf</span>\r\n</div>\r\n```\r\n\r\n## Expected behavior\r\n<!-- Describe what the desired behavior would be. -->\r\n\r\nTemplateref should be accessible from outside of the ngIf and any other structural directive.\r\n`@ViewChild` also should work.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n<!--\r\nFor bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n-->\r\nhttps://plnkr.co/edit/XerE9poibEU3os87y5Bs?p=preview\r\n\r\nClick show and log button.\r\nCheck the javascript console.\r\n\r\n\r\n## Environment\r\n\r\n<pre><code>\r\nAngular version: 4.4.3\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\nBrowser:\r\n- [X] Chrome (desktop) version 60\r\n- [ ] Chrome (Android) version XX\r\n- [ ] Chrome (iOS) version XX\r\n- [ ] Firefox version XX\r\n- [ ] Safari (desktop) version XX\r\n- [ ] Safari (iOS) version XX\r\n- [ ] IE version XX\r\n- [ ] Edge version XX\r\n \r\nFor Tooling issues:\r\n- Node version: XX  <!-- run `node --version` -->\r\n- Platform:  Windows\r\n\r\nOthers:\r\n<!-- Anything else relevant?  Operating system version, IDE, package manager, HTTP server, ... -->\r\n</code></pre>\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/371901255","html_url":"https://github.com/angular/angular/issues/19316#issuecomment-371901255","issue_url":"https://api.github.com/repos/angular/angular/issues/19316","id":371901255,"user":{"login":"darkbasic","id":1047358,"avatar_url":"https://avatars1.githubusercontent.com/u/1047358?v=4","gravatar_id":"","url":"https://api.github.com/users/darkbasic","html_url":"https://github.com/darkbasic","followers_url":"https://api.github.com/users/darkbasic/followers","following_url":"https://api.github.com/users/darkbasic/following{/other_user}","gists_url":"https://api.github.com/users/darkbasic/gists{/gist_id}","starred_url":"https://api.github.com/users/darkbasic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkbasic/subscriptions","organizations_url":"https://api.github.com/users/darkbasic/orgs","repos_url":"https://api.github.com/users/darkbasic/repos","events_url":"https://api.github.com/users/darkbasic/events{/privacy}","received_events_url":"https://api.github.com/users/darkbasic/received_events","type":"User","site_admin":false},"created_at":"2018-03-09T18:21:49Z","updated_at":"2018-03-09T18:21:49Z","author_association":"NONE","body":"> Workaround is\r\n@ViewChild('ref') ref\r\n\r\nThis is not very useful if you're inside an *ngFor :)"}}
{"actor":{"display_login":"darkbasic"}}