title: Displaying module constants or values
body: <p>If I define an angular.module with some constants or values, what is the simplest way to display them in the view?</p>
  
  <p>For instance, given </p>
  
  <pre><code>angular.module('MyApp', [])
    .constant('APPLES', 4)
  </code></pre>
  
  <p>How can I display the value of <code>APPLES</code>? I'd like to be able to do something like this:</p>
  
  <pre><code>&lt;html ng-app="MyApp"&gt;
    &lt;head&gt;...&lt;/head&gt;
    &lt;body&gt;
      &lt;p&gt;There are {{ APPLES }} apples.&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But that doesn't work.</p>
  
  <hr>
  
  <p>The simplest way I've gotten it to work (which is quite complicated, and not scalable if there are many such constants) is this:</p>
  
  <pre><code>angular.module('MyApp', [])
    .constant('APPLES', 4)
    .directive('numApples', ['APPLES', function(apples){
      return function(scope, elm, attrs) {
        elm.text(apples);
      };}])
  </code></pre>
  
  <p>And use the view:</p>
  
  <pre><code>&lt;html ng-app="MyApp"&gt;
    &lt;head&gt;...&lt;/head&gt;
    &lt;body&gt;
      &lt;p&gt;There are &lt;span num-apples&gt;&lt;/span&gt; apples.&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've created a demo <a href="http://plnkr.co/edit/yjsAJPE9PqjdGqMK7mVm?p=preview" rel="nofollow noreferrer">here<img src="https://i.stack.imgur.com/q8hp0.png" alt="screeny"></a>.</p>