Reputation: 863
I have a button in the fist div that triggers the second div to show if clicked. It is simple and straight forward. But the second div does not show.
HTML
<div class="alert alert-danger">
Blah
<button ng-click = "toggleDetail()" class = "btn btn-default"> <span class = "glyphicon glyphicon-zoom-in"></span> </button>
</div>
<div class="alert alert-warning" ng-show = "showDetail">
clicked button
</div>
Controller
$scope.showDetail = false;
$scope.toggleDetail = function() {
$scope.showDetail = !$scope.showDetail;
};
PS. I followed example from http://www.w3schools.com/angular/tryit.asp?filename=try_ng_events
Upvotes: 0
Views: 142
Reputation: 2683
everything seems to be Ok in your example. If you just do such simple stuff you don't have to use a controller function, you can do everything in html
<div ng-init="showDetail=false" class="alert alert-danger">
Blah
<button ng-click = "showDetail = !showDetail" class = "btn btn-default"> <span class = "glyphicon glyphicon-zoom-in"></span> </button>
</div>
<div class="alert alert-warning" ng-show = "showDetail">
clicked button
</div>
Upvotes: 1