Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add attribute without value

Tags:

angularjs

I'm working on one of my first angular templates. While looping through an array, I would like to add the attribute required.

Every itteration of the array looks like this:

        {
            label: 'Last Name',
            name: 'lastname',
            key: 'entry.1417082936'
        }

I could simply add

            {
                label: 'Last Name',
                name: 'lastname',
                key: 'entry.1417082936',
                required: 'required', 
            }

and then add {{required}} to the template, but i'm wondering wether there is a cleaner way of doing it. I will need to add the pattern-attribute as well.

If the requierd: true is set I want the attribute requierd to be included into the html, to something like this:

<input required />

like image 852
Himmators Avatar asked Jun 15 '26 22:06

Himmators


1 Answers

Why don't you use a Boolean ? This is typically a good case for that !

like image 169
LoremIpsum Avatar answered Jun 20 '26 10:06

LoremIpsum