angularjsangularjs-ng-switch

ng-switch to place elements


Any better way to write this? I just dont want to repeat the inner content of the list twice.

 <div ng-switch on="list.type">
   <ul ng-switch-when="unorder">
    <li ng-repeat="item in items">
            {{ item.text }}
    </li>
   </ul ng-switch-when="unorder">
    <ol ng-switch-when="order">
        <li ng-repeat="item in items">
            {{ item.text }}
        </li>
    </ol ng-switch-when="order">
 </div>

Solution

  • I think this is more elegant way by using css instead of using custom-directive for something quite simple

    Html

    <ol ng-class="{'no-style' : list.type === 'unorder'}">
        <li ng-repeat="item in items">
            {{ item.text }}
        </li>
    </ol>
    

    CSS

    ol.no-style {
        list-style-type: none;
    }
    

    Live example you can see here