title: Angular method for querySelectorAll and getElementsByTagName
body: <p>I am very new in Angular. I need a beginner's guide on the best way to define functions to get the length or count of tag (such as div) and Id/Class (#blah or .blah) via querySelectorAll and getElementsByTagName, so it can be called on html template and get current count of the particular elements on page.</p>
  
  <pre><code>function countTag(value1, value2) {
    var top_level_div = document.getElementById(' + value1 + ')
    top_level_div.document.getElementsByTagName(' + value2 + ’).length
  }
  
  function countElem(value) {
    document.querySelectorAll(' + value + ’).length
  }
  </code></pre>
  
  <p>How to angularize the above 2 functions, so they can be call on html template anywhere inside the app? If directive may be a method to do so, can anyone help with a plnkr example?</p>