I am new to angular, I have a requirement where I need to add many custom attributes to a custom element directive, <radio-button>
. Currently, I am doing like this:
<radio-button one-attr="some value" two-attr="some string" three-attr="some other string"><radio-button>
I have many radio buttons on the page and writing custom attributes to each custom directive on that page looks messy. So, I am looking for an alternative where I can pass a javascript array object which loops on each radio-button
custom directive.
For example: (In controller)
$scope.values = [{
'one-attr': 'some value',
'two-attr': 'some other value',
'three-attr': 'another value',
/* and so on... */
},
{
/* another custom attribute set */
}
/* so on */
]
and then to my custom directive, I will pass an custom attribute directive
as shown below:
<radio-button ng-repeat="(key, value) in values" loop-attributes="key, value"></radio-button>
Where above loop-attributes
is a custom attribute directive applied to the custom element directive.
Please suggest how to do this.
If I am going wrong please suggest me how to handle this.