Example:
<div ng-show="{{ display }}">
...
</div>
angular.module('mymodule').directive('mydirective', [
function () {
return {
scope: {
display: '='
},
...
};
}]);
Parent:
<div mydirective show="display" ng-repeat="item in items">
</div>
controller.js:
this.display = false //initial value
function updateVisibility(){
this.display = true; //how can I notify the directive of this change?
}
The variable "display" starts as false but later switches to true. However, the directive's scope variable "display" does not reflect this change. How can I ensure that the directive's display variable updates when the parent's display variable is modified? Should I use $scope.$watch or a different method?