<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<div ng-app="app">
<h1>AngularJS $digest by feature: the impossible way</h1>
<p>
In big projects, we have many features with many parts of view.<br />
<span class="keyword">$apply</span> start refreshing the entire page by calling all of the dirty-checking algorythms and then update the DOM elements. Fine, DOM is not modified if it's unnecessary. But calling all of these algos can take lots of time.
</p>
<p>
Instead of calling <span class="keyword">$apply</span> everytime, it's possible to use <span class="keyword">$digest</span> to refresh a specific <span class="keyword">$scope</span>. Ok so it's possible to call just the algos we wants for specific features instead of the big page.
</p>
<h2>The first problem:</h2>
<p>
All of the AngularJS behaviors are based on calling <span class="keyword">$apply</span>, when the user click buttons, with XHR requests, etc. Unless you want to re-code all of these features, $apply will be called many many times.<br />
In my point of view, the developer should have the control of which features he want to <span class="keyword">$digest</span> instead of the whole page. It's the basic of a complicated UI with lots of components. Actually it's not possible to have a big project in a single page with many features with AngularJS. This is problematic because AngularJS is designed for this use. Try using Drag&Drop with many components, it's the end of the world.
</p>
<h2>My simple example:</h2>
<p>
We have 3 features. We just want to <span class="keyword">$digest</span> "Feature A" and "Feature C" when user interacts with "Feature A". With a simple ng-click it's not possible because it calls <span class="keyword">$apply</span> that calls <span class="keyword">$digest</span> of "Feature...