Dan Kanze
Dan Kanze

Reputation: 18595

Dynamic HTML attributes with ng-repeat AngularJS

Can I add HTML attributes dynamically through ng-repeat?

<select>
    <option ng-repeat="thing in things" {{thing.ghosted||'disabled'}}>
        {{thing.name}}
    </option>
</select>

What am I doing wrong here?

Upvotes: 1

Views: 505

Answers (1)

Mike Robinson
Mike Robinson

Reputation: 25159

For something like this, it'd be good to use a directive.

<select>
    <option ng-repeat="thing in things" ng-disabled="thing.ghosted">
        {{thing.name}}
    </option>
</select>

Upvotes: 3

Related Questions