如何使用AngularJS抓取特定的JSON条目?

问题描述 投票:0回答:1

这是当前输出的图片。输出图像

我想让它在你点击下载的时候显示活动的标题,而不是每个条目都显示。

加载标题的JS代码是

(function($){
    var titledbApp = angular.module('dsshop', ['angular-loading-bar'])
                            .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
                              cfpLoadingBarProvider.includeSpinner = false;
                              cfpLoadingBarProvider.parentSelector = '#loading-bar-container';
                            }]);

    titledbApp.controller('TitleListController', function TitleListController($scope, $http) {
        $http.get('https://nitrobrew.github.io/BrewShopNitro/list0.json').then(function(response){
            $scope.titles = response.data.sort(function(a, b){
              if(a.name.toUpperCase() < b.name.toUpperCase()) return -1;
              if(a.name.toUpperCase() > b.name.toUpperCase()) return 1;
              return 0;
            });
        });
    });

    //Filesize filter, credit to https://gist.github.com/yrezgui/5653591
    titledbApp.filter( 'filesize', function () {
        var units = [
            'bytes',
            'KB',
            'MB',
            'GB',
            'TB',
            'PB'
        ];

        return function( bytes, precision ) {
            if ( isNaN( parseFloat( bytes )) || ! isFinite( bytes ) ) {
              return '?';
            }

            var unit = 0;

            while ( bytes >= 1024 ) {
              bytes /= 1024;
              unit ++;
            }

            return bytes.toFixed( + precision ) + ' ' + units[ unit ];
        };
    });
})();

加载模态框(bootstrap模态)的HTML代码是:

<div class="modal fade" id="downloadModal" tabindex="-1" role="dialog" aria-labelledby="downloadModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel" ng-repeat="title in titles">
                    <center>{{title.name}} download menu</center>
                </h4>
            </div>
            <div class="modal-body">
                <a ng-href="{{title.files[0].url}}" title="{{title.files[0].url}}"
                    ng-repeat="title in titles">File 1</a>
                <br>
                <a href="{{title.files[1]}}">{{title.files[1]}}</a>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-blue" data-dismiss="modal"
                    data-toggle="tooltip">Cancel</button>
            </div>
        </div>
    </div>
</div>

任何帮助都是非常感激的!

javascript json angularjs modal-dialog
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.