I want to show element based on the value of property inside controller.
eReaderBook.directive("controlTools", function () {
return {
replace : true,
restrict : "E",
templateUrl : "assets/directives/controlstools.html",
controller : function ($scope) {
$scope.visible = false;
},
link : function (scope, el, attr) {
el.bind("mouseover",function()
{
console.log(scope.visible)
scope.visible = true;
});
el.bind("mouseout",function()
{
console.log(scope.visible)
scope.visible = false;
})
}
};
});
<div class="menuitem"><span class="glyphicon glyphicon-search"></span><span ng-show="visible" class="menutext">Toc</span></div>
Inside the directive I have a controller defined with $scope.visible = false
. Everything works fine on page load. I want to change the state to $scope.visible = true
on mouseover
and $scope.visible = false
on mouseout
. Why does scope.visible = true;
not affect ng-show
?