How to How to get innerHtml of html div element in angular 1.0 controller js file

Smith
Smith
Participant
360 Points
110 Posts

Hi,

I am using angular 1.0. I want innerHtml of html div element in angular controller js file. Similar way as we do in JQuery

$(".ticketformcode").html()

Thanks

Views: 8809
Total Answered: 3
Total Marked As Answer: 1
Posted On: 23-Jun-2017 03:44

Share:   fb twitter linkedin
Answers
edx
edx
52 Points
16 Posts
     

Try this:

var  messageElem = angular.element(document.querySelector('.ticketformcode'))
messageElem.contents()[0].innerHTML
Posted On: 23-Jun-2017 03:48
Smith
Smith
Participant
360 Points
110 Posts
     
var  messageElem = angular.element(document.querySelector('.ticketformcode'))
messageElem.contents()[0].innerHTML

It's not working. It's showing undefined.  But when I checked in console I am getting values messageElem.contents()[0] .

 

 

Posted On: 23-Jun-2017 03:52
edx
edx
52 Points
16 Posts
Marked as answer      

Try this

var messageElem = angular.element(document.querySelector('.ticketformcode'))
ticketformcode = messageElem[0].innerHtml;
Posted On: 23-Jun-2017 03:55
great..
 - chkdk  09-May-2018 20:12
banner

Blog

Active User (2)

 Log In to Chat