2016-10-18 5 views
0

HTML:私はangularjsにTDのテキストを取得したいanglejsを使って隠れたtd要素のテキストを取得する方法は?

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

:よう

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

ページの読み込み後に思えます。私は次のように試しました:

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

しかし、上記のすべての解決法は空の文字列を返します。 誰でも助けてくれますか?

ありがとうございます。

+0

あなたが.textContentを試すか.VALUEたのですか? –

+0

私は値を試しましたが失敗しました。 –

+0

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent。ドキュメントでは.textContentは –

答えて

1

あなたはアンガージャーを使用していますが、ジェイクではありません。だから、ちょうど怒鳴るようにNG-モデルを設定する必要があります。 HTML

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

JS

console.log('DATA IS ',$scope.msg.location); 
関連する問題