Skip to content

Instantly share code, notes, and snippets.

@jonocairns
Created September 11, 2016 22:43
Show Gist options
  • Save jonocairns/510cc94964523d25c10de79733dd6960 to your computer and use it in GitHub Desktop.
Save jonocairns/510cc94964523d25c10de79733dd6960 to your computer and use it in GitHub Desktop.
Multiselect angular with form validation
public isMultiSelectOptionSelected(object: any): boolean {
return object && Object.keys(object).some(key => object[key]);
}
<label ng-repeat="option in question.options">
<input ng-required="!vm.isMultiSelectOptionSelected(question.selectedAnswer)" type="checkbox" ng-model="question.selectedAnswer[option]" name="{{question.id}}" />
<span class="input custom-check"></span>
<span class="question-label">{{option}}</span>
</label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment