Answer the question
In order to leave comments, you need to log in
Angularjs. Why do page changes only happen after $apply?
There are 2 inputs
<input type="text" class="search-input real-search-input" data-ng-hide="showFakeInput"/>
<input type="text" class="search-input fake-search-input " disabled="disabled" data-ng-show="showFakeInput" />
$scope.showFakeInput = false;
$rootScope.$on('showFakeSearchInput', function () {
$scope.showFakeInput = true;
});
$rootScope.$on('hideFakeSearchInput', function () {
$scope.showFakeInput = false;
});
$rootScope.$on('hideFakeSearchInput', function () {
$scope.showFakeInput = false;
$scope.$apply();
});
Answer the question
In order to leave comments, you need to log in
You do not understand how data-binding works in Angular. That is, you did not understand the very cornerstone on which the angular is based.
$apply invokes a $digest loop on the rootScope that compares the current value with the last saved value. If there are changes, the watcher starts.
So the short answer is no, nothing will work without $apply. Long answer - www.sitepoint.com/understanding-angulars-apply-digest
I'm reading this
ata binding means that when you change something in the view, the scope model automatically updates. Similarly, whenever the scope model changes, the view updates itself with the new value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question