I want to use the $scope to set if an attribute should be used or not in angular. Here is my scope:
fields:
[
{
label: 'First Name',
name: 'firstname',
key: 'entry.326845034',
type: 'text',
required: true
}
]
it's the required attribute I want to set. I'm imagining something like {{if fields.required == true | required}}
, but I can''t find any documentation on it.
Are you wanting to set required on a form element like this?
<input required>
If so you can use
<input ng-required="fields.required">
and the true/false state of the variable will end up applying or removing the required attribute on the input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With