0

I am building my first angularjs app and my project has 3 entities. I am getting their model in json form. for example

return [
            { "name": "IsActive", "type": "checkbox", "default": "true", "icon": "check" },
            { "name": "Name", "type": "text", "required": "true", "default": "", "icon": "user" },
            { "name": "Email", "type": "email", "validation": "email", "default": "", "icon": "envelope" },
            { "name": "Phone", "type": "text", "default": "", "icon": "phone" },
            { "name": "Fax", "type": "text", "default": "", "icon": "fax" },
            { "name": "Mobile", "type": "text", "default": "", "icon": "mobile" },
            { "name": "Address", "type": "text", "default": "", "icon": "map-marker" },
            { "name": "ContactPerson", "type": "text", "default": "", "icon": "comment" }
        ];

With the entities' model i dynamically create their add forms. Here is part of my html:

<div class="addInpRow row" ng-repeat="m in vm.accounts.emodel">
   <input name="{{m.name}}" type="{{m.type}}"/>
 </div>

What i want to do is echo the required attribute if it is true.

I have tried several things to print it but nothing does the job. Some things that i have tried are:

<input name="{{m.name}}" {{m.required ? 'required' : ''}} />
<input name="{{m.name}}" aria-required="{{m.required}}" />

and many variations of what my m.required looks, like 'required="required".

Any help would be much appreciated. Thanks

2 Answers 2

1

Use

<input name="{{m.name}}" ng-required="m.required">
Sign up to request clarification or add additional context in comments.

Comments

1

Use ng-required instead.

<input name={{m.name}} ng-required=m.required>

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.