{"action":"opened","issue":{"url":"https://api.github.com/repos/angular/angular/issues/9610","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/9610/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/9610/comments","events_url":"https://api.github.com/repos/angular/angular/issues/9610/events","html_url":"https://github.com/angular/angular/issues/9610","id":162316914,"number":9610,"title":"How to get elementRef in service?","user":{"login":"phevose","id":7766085,"avatar_url":"https://avatars.githubusercontent.com/u/7766085?v=3","gravatar_id":"","url":"https://api.github.com/users/phevose","html_url":"https://github.com/phevose","followers_url":"https://api.github.com/users/phevose/followers","following_url":"https://api.github.com/users/phevose/following{/other_user}","gists_url":"https://api.github.com/users/phevose/gists{/gist_id}","starred_url":"https://api.github.com/users/phevose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phevose/subscriptions","organizations_url":"https://api.github.com/users/phevose/orgs","repos_url":"https://api.github.com/users/phevose/repos","events_url":"https://api.github.com/users/phevose/events{/privacy}","received_events_url":"https://api.github.com/users/phevose/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-06-26T07:50:04Z","updated_at":"2016-06-26T07:50:04Z","closed_at":null,"body":"I want pass component‘s ViewContainerRef or elementRef to service(Injectable),as below:\r\n-------a.component.ts--------\r\n```\r\nimport { Component,ElementRef} from '@angular/core';\r\nimport {ModalService} from './kit/modal.service';\r\n@Component({\r\n  selector: 'routea',\r\n  template: require('./a.component.html'),\r\n  styles: [`....`],\r\n  providers: [ModalService]\r\n})\r\nexport class AComponent {\r\n  constructor(private modalService: ModalService) {}\r\n  edit(){\r\n    this.modalService.alert();\r\n  }\r\n}\r\n```\r\n------------modal.service---------\r\n```\r\nimport { Injectable,Component,ComponentResolver,ViewContainerRef,} from '@angular/core';\r\n@Injectable()\r\nexport class ModalService {\r\n    constructor(private compiler: ComponentResolver,private viewContainerRef:ViewContainerRef) { \r\n        \r\n    }\r\n    alert(){\r\n        console.log(this.viewContainerRef.element);\r\n    }\r\n}\r\n```\r\nbut this not work.error:No provider for ViewContainerRef!\r\nso how can i get invoker(component) viewContainerRef in callees?"}}
{"actor":{"display_login":"phevose"}}