Angular JS - NgSwitch Example German

by scyrizales

HTML

<div ng-app="" ng-controller="Test">
    <ul class="dropdown-menu" ng-switch="isMediaFile(row.entity)">
        <!-- In case that the row is a Video -->
        
        <li ng-switch-when="true" ng-show="!row.getProperty('source_url')">
            <a href="" adap-video-modal="videoFiles"
            data-index="row.rowIndex" data-array="files">
                first
            </a>
        </li>
        <li ng-switch-when="true" ng-show="!row.getProperty('transcodeError')">
            <a ng-href="{{ row.getProperty('url') }}" target="_blank" download>
                second
            </a>
        </li>
        <li ng-switch-when="true" ng-show="!row.getProperty('transcodeError')">
            <a adap-view-url="row.getProperty('url')">
                third
            </a>
        </li>
        <li ng-switch-when="true" ng-show="!row.getProperty('source_url')">
            <a href="" adap-transcode-options-modal="videoFiles" data-index="row.rowIndex">
                fourth
            </a>
        </li>
        <li ng-switch-when="true" ng-show="row.getProperty('transcodeError')"
        ng-click="row.getProperty('retryTranscode')(row.rowIndex)">
            <a href="">
                fifth
            </a>
        </li>
        <li ng-switch-when="true" class="divider">divider</li>
        <li ng-switch-when="true" ng-show="!row.getProperty('transcodeError')">
            <a href="" ng-click="videoFiles.deleteVideo(row.rowIndex)">
                sixth
            </a>
        </li>
    </ul>
</div>

JavaScript

function Test($scope){
    $scope.row = {
        getProperty: function(value){
            return false;
        }
    };
    $scope.isMediaFile = function (entity){
        return true;
    }
}