Skip ng-repeat JSON ordering in Angular JS

后端 未结 4 1723
难免孤独
难免孤独 2020-11-30 06:02

Does anybody know how I can SKIP JSON ordering altogether when I use ng-repeat (in a painless way probably)?

For example, my source JSON looks somet

4条回答
  •  迷失自我
    2020-11-30 06:50

    I am using this approach to override the alphabetical ordering:

    Controller:

    $scope.steps = {
        "basic-settings": "Basic Settings",
        "editor": "Editor",
        "preview-and-publish": "Preview & Publish"
    };
    
    // NOTE I realise this is a hacky way, but I need to override JS's alphabetical ordering
    $scope.stepsKeys = _.keys($scope.steps);
    
    $scope.activeStep = 0;
    

    PLEASE NOTE that _.keys($scope.steps); is LoDash substituting Object.keys();

    HTML:

    • {{ steps[key] }}

提交回复
热议问题