Could you please help me with validating a radiogroup using AngularJS, which is instantiated within an additional directive?
The validation requirement is that the User must not be able to submit unless one of the radio buttons has been selected.
This is how I have set it up:
HTML document :
<ng-form name="salutationgroup">
<radiotrigger model="mrms" name="gender" value='1' label="mr" ></radiotrigger>
<radiotrigger model="mrms" name="gender" value='2' label="ms" ></radiotrigger>
</ng-form>
JS document:
Directives.directive('radiotrigger', function() {
return {
restrict: 'E',
scope: {},
compile: function(element, attrs) {
var templateText = '<li><label><input type="radio" ng-model="' +
attrs.model + '" value="' +
attrs.value + '">' +
attrs.label + '</label></li>';
element.replaceWith(templateText);
}
};
});
Thank you for your assistance.