I am new to AngularJS. I am trying to get the checkbox to appear as checked from previously selected value. I thought ng-class would do the trick but it's not. Did I do anything wrong in the code below?
Here is my HTML code:
<ul class="dropdown-menu menu-content" uib-dropdown-menu>
<li ng-repeat="value in values" >
<label><input type="checkbox" ng-class="{'checked' : value.selected, 'active' : value.selected}" ng-click="$ctrl.toggleValue(value)">{{value.valueName}}</label></li>
</ul>
<body>
<script>
var app = angular.module("myShoppingList", []);
app.controller("myCtrl", function($scope) {
// dummy data
$scope.value = 1; // some value
});
</script>
<div ng-app="myShoppingList" ng-controller="myCtrl">
<input type="checkbox" ng-checked="value === 1">
</div>
</body>
Use inbuilt ng-checked directive of angular.