Created
September 11, 2016 22:43
-
-
Save jonocairns/510cc94964523d25c10de79733dd6960 to your computer and use it in GitHub Desktop.
Multiselect angular with form validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public isMultiSelectOptionSelected(object: any): boolean { | |
return object && Object.keys(object).some(key => object[key]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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