0

I need to contruct the following

<button large></button>
<button larger></button>

I would like to do something like...

<!-- where items = ["large", "larger"] -->

<button ng-repeat="item in items" {{item.type}}>Whatever</button>

How would I go about this? I tried the above but it didn't seem to work

I would expect...

<button large class="ng-binding">Whatever</button>
<button larger class="ng-binding">Whatever</button>

but I get

<button {{item.type}} class="ng-binding">Whatever</button>
<button {{item.type}} class="ng-binding">Whatever</button>

As you can see the button fails to have the appropriate attr.

2
  • You cannot really do this directly with bindings, after all this is a super weird requirement :). There are even places where you can dynamically set attribute values using ng-attr (ng-attr-custtype="{{item.type}}" will set custtype="large" etc) or You could even set ng-class. What are you achieving by doing <button large etc..? sorry this makes no sense to me... If you really want you would need to create a directive which sets attribute on the element Commented Oct 29, 2014 at 2:24
  • Yeah it is weird and essentially due to the library I was trying to use so I ended up rewriting the library that way but the question remains the Same. Another example I can think of is porting weird jQuery libs Commented Oct 29, 2014 at 3:26

0

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.