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

Smith
Smith
Participant
374 Points
112 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: 9200
Total Answered: 3
Total Marked As Answer: 1
Posted On: 23-Jun-2017 03:44

Share:   fb twitter linkedin
Answers
edx
edx
54 Points
17 Posts
         

Try this:

var  messageElem = angular.element(document.querySelector('.ticketformcode'))
messageElem.contents()[0].innerHTML
Posted On: 23-Jun-2017 03:48
Smith
Smith
Participant
374 Points
112 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
54 Points
17 Posts
         

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
 Log In to Chat