count number of child elements in AngularJS
<p>I went through many answers to find how to count number of child elements in <code>Angular JS</code> but I didn't understood. Please have a look at my simple code and suggest me super <strong>simple</strong> method of counting no of childs.</p>

<p>I want count the total child under <code>&lt;div id="myDiv"&gt;</code> and total <code>span</code> elements under <code>&lt;div id="myDiv"&gt;</code>. </p>

<p>Here total <code>no of child = 5</code> and total <code>span elements = 3</code></p>

<pre><code>&lt;html&gt;
    &lt;body ng-app="myApp" ng-controller="myCtrl"&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;

        &lt;button ng-click="countElem()"&gt;Count&lt;/button&gt;
        &lt;div id="myDiv"&gt;
            &lt;span&gt;child 1&lt;/span&gt;
            &lt;span&gt;child 2&lt;/span&gt;
            &lt;span&gt;child 3&lt;/span&gt;
            &lt;p&gt;child 4&lt;/p&gt;
            &lt;p&gt;child 5&lt;/p&gt;
        &lt;/div&gt;

        &lt;script&gt;
            var app = angular.module("myApp", []);
                app.controller("myCtrl", function($scope){

            });
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>