title: AngularJS count html attributes occurrence in each controller
body: <p>I hava a SPA AngularJS app with 2 views (2 controllers A and B). I need to count the number of occurrences of attribute x in each controller.</p>
  
  <p>I count doing <code>document.querySelectorAll('[x]')</code> in both controllers.</p>
  
  <p>For instance:</p>
  
  <p>View 1 (controller A) has 1 occurrence of attribute "x".
  View 2 (controller B) has 2 occurrences of attribute "x".</p>
  
  <p>So when I go from View 1 -> View 2 the count will be "erroneously" 3 occurrences of x in controller B. I assume it has to do with being a SPA and the html is already loaded in memory or something like that?</p>