I have a checkbox:
<input ng-model="defaultAssigneeCheckbox" type="checkbox"/>
<p>{{defaultAssigneeCheckbox}}</p>
<button type="submit">Save</button>
Paragraph below it shows and updates its state properly between false
and true
.
Clicking button runs controller function:
$scope.updateProject = function () {
var project = $scope.project;
console.log(typeof $scope.defaultAssigneeCheckbox)
console.log($scope.defaultAssigneeCheckbox)
if (!$scope.defaultAssigneeCheckbox) {
delete project.defaultAssignee;
}
};
When I click button it shows the checkbox as true regardless of whether the checkbox is checked or not.
What am I doing wrong?