{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/6093","labels_url":"https://api.github.com/repos/angular/angular/issues/6093/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/6093/comments","events_url":"https://api.github.com/repos/angular/angular/issues/6093/events","html_url":"https://github.com/angular/angular/issues/6093","id":123667570,"number":6093,"title":"passing elements in the view as arguments to HostListener fails","user":{"login":"kasperpeulen","id":1035299,"avatar_url":"https://avatars.githubusercontent.com/u/1035299?v=3","gravatar_id":"","url":"https://api.github.com/users/kasperpeulen","html_url":"https://github.com/kasperpeulen","followers_url":"https://api.github.com/users/kasperpeulen/followers","following_url":"https://api.github.com/users/kasperpeulen/following{/other_user}","gists_url":"https://api.github.com/users/kasperpeulen/gists{/gist_id}","starred_url":"https://api.github.com/users/kasperpeulen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasperpeulen/subscriptions","organizations_url":"https://api.github.com/users/kasperpeulen/orgs","repos_url":"https://api.github.com/users/kasperpeulen/repos","events_url":"https://api.github.com/users/kasperpeulen/events{/privacy}","received_events_url":"https://api.github.com/users/kasperpeulen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-23T14:23:08Z","updated_at":"2015-12-23T15:07:53Z","closed_at":null,"body":"I have the following dart code:\r\n\r\n```dart\r\n@Component(selector: 'my-app', template: '<textarea #textarea></textarea>')\r\nclass AppComponent {\r\n  @HostListener('click', const ['textarea'])\r\n  hostClick(TextAreaElement textarea) {\r\n    textarea.focus();\r\n  }\r\n}\r\n```\r\n\r\nI hoped this to work, but I get the following error:\r\n```\r\n  EXCEPTION: Error during evaluation of \"click\"\r\n    (anonymous function)\t\r\n  ORIGINAL EXCEPTION: Class 'AppComponent' has no instance getter 'textarea'.\r\n\r\nNoSuchMethodError: method not found: 'textarea'\r\nReceiver: Instance of 'AppComponent'\r\n```\r\n\r\nNow I don't know if this is a bug, or I'm supposed to do this in another way. If so, I would like to learn how I should do this. What I want to achieve is that, if some user clicks somewhere in parent element, it will actually focus the textarea element."},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/166919185","html_url":"https://github.com/angular/angular/issues/6093#issuecomment-166919185","issue_url":"https://api.github.com/repos/angular/angular/issues/6093","id":166919185,"user":{"login":"kasperpeulen","id":1035299,"avatar_url":"https://avatars.githubusercontent.com/u/1035299?v=3","gravatar_id":"","url":"https://api.github.com/users/kasperpeulen","html_url":"https://github.com/kasperpeulen","followers_url":"https://api.github.com/users/kasperpeulen/followers","following_url":"https://api.github.com/users/kasperpeulen/following{/other_user}","gists_url":"https://api.github.com/users/kasperpeulen/gists{/gist_id}","starred_url":"https://api.github.com/users/kasperpeulen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasperpeulen/subscriptions","organizations_url":"https://api.github.com/users/kasperpeulen/orgs","repos_url":"https://api.github.com/users/kasperpeulen/repos","events_url":"https://api.github.com/users/kasperpeulen/events{/privacy}","received_events_url":"https://api.github.com/users/kasperpeulen/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T15:07:53Z","updated_at":"2015-12-23T15:07:53Z","body":"@thelgevold right, this works. However, I was wondering, normally, I would do something like this:\r\n\r\n```\r\n<parent (click)=\"textarea.focus()\"\r\n  <textarea #textarea></textarea>\r\n</parent>\r\n```\r\n\r\nbut now the parent is the host, so I thought, this seems the most logical way, having as template:\r\n```\r\n<textarea #textarea></textarea>\r\n```\r\n\r\nand then passing `textarea` to HostListener\r\n\r\n```dart\r\n  @HostListener('click', const ['textarea'])\r\n  hostClick(TextAreaElement textarea) {\r\n    textarea.focus();\r\n  }\r\n```\r\n\r\n(this is dart code, typescript code is very similar I guess)\r\n\r\nI'm normally trying to avoid having to use `ElementRef` but maybe that is the only solution here?"}}