I am new to angular, I have a requirement when I need to add many custom attributes to the custom elements directive, <radio-button> . I am currently doing this:
<radio-button one-attr="some value" two-attr="some string" three-attr="some other string"><radio-button>
I have a lot of switches on the page and writing custom attributes to each custom directive on this page looks messy. So, I'm looking for an alternative where I can pass a javascript array object that cyclically tunes each custom radio-button directive.
For example: (in the controller)
$scope.values = [{ 'one-attr': 'some value', 'two-attr': 'some other value', 'three-attr': 'another value', }, { } ]
and then in my custom directive, I will pass the 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 a custom element directive.
Please suggest how to do this.
If I'm wrong, suggest me how to handle this.
source share