title: AngularJS - get label text for field
body: <h2>Question</h2>
  
  <p>I was wondering what the AngularJS "best practice" way of getting a label for a field is.  With jQuery you just query using a "label for" query then extract the text.  While it's possible to do it this way with AngularJS, something just doesn't feel right about it.</p>
  
  <p>Assume you have something like this in your HTML:</p>
  
  <pre><code>&lt;form name="MyForm" ng-controller="Ctrl"&gt;
      &lt;label for="MyField"&gt;My spoon is too big:&lt;/label&gt;
      &lt;input type="text" size="40" id="MyField" ng-model="myField" /&gt;
  
      &lt;br /&gt;&lt;br /&gt;
  
      You entered {{ myField }} for {{ myField.label }}
  &lt;/form&gt;
  </code></pre>
  
  <p>The controller internal is pretty simple:</p>
  
  <pre><code>$scope.myField = 'I am a banana.';
  </code></pre>
  
  <p>Basically I want to populate the <code>myField.label</code> in the output with "<em>My spoon is too big.</em>"</p>
  
  <h2>What I'm Doing Now</h2>
  
  <p>All I am doing right now is executing a query that pulls the data similar to the jQuery methodology (<code>$("label[for='MyField']")</code>).  Then, if that doesn't exist I am just pulling the placeholder text.  It works, but it seems like a bit of overhead.</p>
  
  <h2>What I'm Trying to Accomplish</h2>
  
  <p>I want some custom form validation and I want to include the label in the message.  I just need to pull the label text so that I can write it extremely generically and then not have to worry about people switching i18n data in dynamically later in the game.</p>
  
  <h2>Fiddle</h2>
  
  <p>Per the suggested solution:
  <a href="https://jsfiddle.net/rcy63v7t/7/" rel="noreferrer">https://jsfiddle.net/rcy63v7t/7/</a></p>