I have a problem to show and hide a div from a template on HTML page. here is a simple JSFiddle example Example.
app.directive('example', function () {
return {
restrict: 'E',
template: '<button ng-click=\"clickMe()\">Click me</button>',
scope: {
exampleAttr: '@'
},
link: function (scope) {
scope.clickMe = function () {
scope.showMe = !scope.showMe;
};
}
};
});
and the HTML is like that :
<body ng-app="demo" ng-controller="exampleController">
<div>
<div ng-controller="exampleController as ctrl">
<example example-attr="xxx">
<p ng-show="showMe">Text to show</p>
</example>
</div>
</div>
I cant add my html code to the template like in this example because my div that i want to show or hide is an entire html page.
app.directive('example', function () {
return {
restrict: 'E',
template: '<p ng-show=\"showMe\">Text to show</p><button ng-click=\"clickMe()\">Click me</button>',
scope: {
exampleAttr: '@'
},
link: function (scope) {
scope.clickMe = function () {
scope.showMe = !scope.showMe;
};
}
};
});
Thanks in advance