I'm trying to hide a div when I click hide button.But I'm unable to show a div if I click on show button.I'm able to do only one action at a time.
If I set " $scope.showDiv = false;" as default,I'm unable to show the div even though by using the below code:
$scope.getShow = function() {
$scope.showDiv = true;
window.location = "./sample.html";
}
Can anyone please help me out regarding this issue ...
My html code:
<div ng-if="showDiv">Hello</div>
<button style="margin-left: 22px; margin-top: 16px; background-color: #73AD21"
ng-click="getShow()">Show</button>
<button style="margin-left: 22px; margin-top: 16px; background-color: #73AD21"
ng-click="getHide()">Hide</button>
My js code:
$scope.showDiv = false;
$scope.getShow = function() {
$scope.showDiv = true;
window.location = "./sample.html";
}
$scope.getHide = function() {
$scope.showDiv = false;
window.location = "./sample.html";
}
I'm trying to access main page from my home page.when I click show button in the home page,it should redirect to main page and show the div.when I click hide button in the home page,it should redirect to main page and hide the div.This is what I'm unable to do currently.
window.locationinsidegetShowandgetHidefunction?window.location = "./sample.html";everywhere? Remove it, and it should work fine.ng-if="showDiv"actually refers to a$scope.showDivof a different scope. Take a look into the basics of angular scope and angular routing and good luck!