Question about "scope" in angularJS I try to show a loading animation when i do a search.
In my controller i create a var called "loader" and in the HTML i put ng-show="loader" on the div that i would like to show/hide
Simple... But...
I can show the loader but can't hide it...
Here is my code...
HTML :
<secion ng-controller="ContactsCtrl">
<div class="loader" ng-show="loading"></div>
<h2>Contacts</h2>
<form class="form-search">
<input type="text" ng-model="s_search" placeholder="Search for a contact...">
<button type="submit" class="btn" ng-click="search()">Search</button>
</form>
<div id="resultContact"></div>
</section>
JS :
function ContactsCtrl($scope){
$scope.loading = false;
$scope.endLoading = function(){
$scope.loading = false;
}
$scope.search = function() {
$scope.loading = true;
setTimeout($scope.endLoading, 1000);
}
}
I suppose the problem is with the "scope inherits" but i don't see my mistake