I am working on a form that consists of checkboxes representing the days of the week. When the user hits submit without selecting any checkboxes, I want an error message to appear. Here is the HTML code snippet that I have:
<form id="addEditForm" name="addEditForm" ng-submit="addEditForm.$valid && saveBooking()" novalidate>
<div ng-repeat="item in days">
<md-checkbox ng-required="daysSelected.length == 0" ng-checked="dayExists(item, daysSelected)" ng-click="toggleWeekdays(item, daysSelected)" name="daysOfWeek">{{ item }}</md-checkbox>
</div>
<div flex ng-messages="addEditForm.daysOfWeek.$error" ng-if="addEditForm.$submitted">
<div ng-message="required">Please select a day.</div>
</div>
<md-button aria-label="Save Booking" class="md-primary-short" type="submit">Save</md-button>
</form>