Background:
Im working on an angular app that displays a list of articles. The list can be changed by various settings. One such setting is the source of these articles. Think of the source as a news agency: the article comes from a specific source:

Therefore, when the user clicks the Sources link, a drop-down menu should appear that contains a list of sources. The user can select any combination of these sources. There are also buttons "Select All" and "Clear All" to select all sources or deselect all of them:

:
, , HTTP- , .
, , , http- ( updateArticleList()).
1) ng-click label:
<ul>
<li ng-repeat="source in sources">
<label ng-click="updateArticleList()">
<input type="checkbox" ng-model="source.selected">
{{source.title}}
</label>
</li>
</ul>
( label , -, input). .
2) ng-change input:
<ul>
<li ng-repeat="source in sources">
<label>
<input type="checkbox" ng-model="source.selected"
ng-change="updateArticleList()">
{{source.title}}
</label>
</li>
</ul>
, " " "", HTTP-. .
, setTimeout, , ( ng-click):
var requestAllowed = true;
var debounceRequests = function(){
requestAllowed = false;
setTimeout(function(){
requestAllowed = true;
}, 5);
};
scope.updateArticleList = function(){
if (requestAllowed === true){
debounceRequests();
setTimeout(function(){
getArticles();
}, 5);
}
};
.
, , HTTP- ?
, js-.
==================
:
, " " :
scope.selectAllSources = function(){
scope.sources.forEach(function(source){
source.selected = true;
});
scope.updateArticleList();
};