Goal: I want to display the content of a div based on checkboxes' status but also want to have these div visible by default
Assuming I have the following piece of code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
</head>
<body ng-app>
<label>red <input type="checkbox" ng-model="red" /></label><br />
<label>blue <input type="checkbox" ng-model="blue" /></label><br />
<div ng-show="red" style="width: 50px; height: 50px; background-color: red;"></div><br />
<div ng-show="blue" style="width: 50px; height: 50px; background-color: blue;"></div><br />
<div ng-show="red" style="width: 50px; height: 50px; background-color: red;"></div><br />
</body>
</html>
With this code, my 2 checkboxes are not checked by default, and each div is correctly displayed whenever I check one of the two checkboxes
Now I tried to append:
ng-checked='true'
By default my checkboxes are now selected but the div are still not displayed. I tried to poke around with some ng-init, ng-hide or ng-load but my experience with Angular is really limited.
Anyone can point me to a direction?