0

HTML:

<td hidden ng-bind="msg.location" id="msg_location"></td>

After page loading it seems like:

<td hidden ng-bind="msg.location" id="msg_location">/2/</td>

i want to get text of td in angularjs. I tried following:

angular.element('#msg_location').html()
angular.element('#msg_location').text()
angular.element('#msg_location').innerHTML

but all of above soltions returns empty string. Can anyone help me?

thanks in advance.

6
  • did you try .textContent or .value? Commented Oct 18, 2016 at 13:21
  • i tried .value but failure. Commented Oct 18, 2016 at 13:22
  • developer.mozilla.org/en-US/docs/Web/API/Node/textContent as per documentation .textContent should do Commented Oct 18, 2016 at 13:24
  • why can't you directly use 'msg.location' in angular controller. example - var location = msg.location; I'm assuming msg.location is your model. Commented Oct 18, 2016 at 13:24
  • @Anirudh:angular.element('#msg_location').textContent gives undefined. Commented Oct 18, 2016 at 13:26

1 Answer 1

1

BECAFULL YOU USE ANGULARJS AND NOT JQUERY. So you just need to set a ng-model like bellow: html

<td hidden ng-model='msg.location' ></td>

JS

console.log('DATA IS ',$scope.msg.location);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.