1

i was trying to access my element this way:

@ViewChild('addNodeDefinition' , {read: ElementRef}) editNodeModal: ElementRef;

but i get error:

'ElementRef' only refers to a type, but is being used as a value here.

my html:

<ng-template #addNodeDefinition></ng-template>

what's the problem? thanks

Fateme Fazli
  • 11,582
  • 2
  • 31
  • 48
  • The post here should help. https://stackoverflow.com/questions/32693061/how-can-i-select-an-element-in-a-component-template#answer-35209681 It's possible you need to chang `{read: ElementRef}` to `{read: ViewContainerRef}` – peinearydevelopment Apr 25 '18 at 12:57
  • @peinearydevelopment thanks but my problem is i didn't use ```ElementRef``` as a value but i got this error. – Fateme Fazli Apr 25 '18 at 13:03
  • 1
    You are using it as a value though. `{read: ElementRef}`. That is a JavaScript object, `read` is the property name and `ElementRef` is the value you are assigning to that property. – peinearydevelopment Apr 25 '18 at 13:05

0 Answers0