2

I am using AngularJS with twitter bootstrap. The fiddle for my issue can be found here.

The HTML code in question here is:

<button type="button" class="btn" ng-repeat="tool in toolBar">
    <div ng-switch on="tool.action">
        <i class="icon-plus-sign" ng-switch="insert"></i>
        <i class="icon-edit" ng-switch-when="edit"></i>
        <i class="icon-trash" ng-switch-when="delete"></i>
    </div>
</button>

and the scope is:

$scope.toolBar = [
    {
        "action": "insert"
    },
    {
        "action": "edit"
    },
    {
        "action": "delete"
    }        
];

Problem is that I want the icons to be displayed only one per button but somehow the more than two icons are shown.

What am I doing wrong?

2
  • 2
    you are missing "when" on the first icon. If you fix that it will work. Commented Apr 8, 2013 at 21:02
  • Thanks! Could you just mention this as the answer so that I can close this question Commented Apr 8, 2013 at 21:15

1 Answer 1

4

You are missing a when.

Replace your html with

<button type="button" class="btn" ng-repeat="tool in toolBar">
    <div ng-switch on="tool.action">
        <i class="icon-plus-sign" ng-switch-when="insert"></i>
        <i class="icon-edit" ng-switch-when="edit"></i>
        <i class="icon-trash" ng-switch-when="delete"></i>
    </div>
</button>

and it should work fine.

Sign up to request clarification or add additional context in comments.

Comments

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.