Mohammad Hamid
Mohammad Hamid

Reputation: 11

How to get access to html element content (text, other components, Images) in angular 2

I am trying to use an editable div tag and after editing I am trying to access its content using angular 2 syntax:

<div contenteditable="true" > {{sentence}} </div>

Upvotes: 0

Views: 116

Answers (1)

Teddy Sterne
Teddy Sterne

Reputation: 14201

You can access the innherHTML property of the div to find out the content of the div like so:

<div contenteditable="true" (blur)="contentChanged($event.currentTarget.innerHTML)">
    {{sentence}}
</div>

Demo

Upvotes: 1

Related Questions