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'); }
you have parenthesis in code.
conole.log( $(this.item.nativeelement).attr('id')) );
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
Post a Comment