Ok i have main header controller where i have this:
<div class="fade-show-hide" ng-class="{'ng-hide':loggedInClose==true}" ng-show="loggedInOpened" ng-cloak>
@Html.Partial("~/Views/Shared/_LoggedInPartial.cshtml")
</div>
In script i have this:
$scope.loggedInClose = false;
$scope.toggleLoggedIn = function () {
$scope.loggedInOpened = !$scope.loggedInOpened;
$scope.languagesOpened = false;
$scope.loginOpened = false;
};
Problem is when i use this code nothing happend...i get $scope.loggedInClose = true;
but div is not hide ...
angular.element(document).on('click', function () {
$scope.loggedInClose = true;
});
Can someone explain me how to hide div if i click anywhere on page that?
I hope you put this event listener in directive, not in controller? :) Anyway, you need to tel Angular to update scope bindings. For this call $apply method to kick off new digest:
angular.element(document).on('click', function () {
$scope.loggedInClose = true;
$scope.$apply();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With