angular - How to get ID of element ViewChild angular2 and jquery? -


i need have relation between jquery , viewchild of angular2

i tried undefined value

@viewchild('item', {read: viewcontainerref}) item;  console.log( $(this.item.nativeelement).attr('id')) ); 

update part

<div class="container col411 col-sm-4" id="div411item"          style="border: 1px solid #9da0a4;" (dblclick)="activeeditcol411()" #item>     new content </div>  activeeditcol411(){     $('#item').prop('contenteditable','true'); } 

  1. you have parenthesis in code.

    conole.log( $(this.item.nativeelement).attr('id')) );

  2. are sure have id attribute in html tag? if don`t have one, add , try code below: console.log( $(this.item.nativeelement).attr('id') );

answer updated:

<div class="container col411 col-sm-4" id="div411item"  style="border: 1px solid #9da0a4;" (dblclick)="activeeditcol411()" #item> new content </div>  @viewchild('item', {read: viewcontainerref}) item;  activeeditcol411(){     $(this.item.element.nativeelement).prop('contenteditable','true');  } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -