0

this work

<input type="text" aaa="{{field.isRequired | requiredx}}" ng-model="field.input.model">

output

<input type="text" aaa="required" class="form-control ng-pristine ng-valid" ng-model="field.input.model">

but this not work

<input type="text" required="{{field.isRequired | requiredx}}" ng-model="field.input.model">

output

<input type="text" required="{{field.isRequired | requiredx}}" class="form-control ng-pristine ng-valid ng-valid-required" ng-model="field.input.model">

....

Edit, add filter:

angular.module('appFilters', []).filter('requiredx', function() {
return function(input) {
    return input ? 'required' : '';
};

}); Anyone have an idea how make it work?

1 Answer 1

1

Use ng-required, you can't set HTML5's required attribute like that. Try this:

<input type="text" ng-required="(field.isRequired | requiredx)" ng-model="field.input.model">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.