我有一个从Servlet自动生成的多层Json。然后我使用AngularJS中的脚本在HTML内的模式对话框中的(键,值)中显示此Json。模态对话框有许多选项卡,每个选项卡都用Json的键命名,并且在理论上还包含值。
我想要的是在选项卡中正确显示通讯对象的值,而不是全部对象。
那是我的杰森

    {
      "mission": {
        "codice": "4",
        "descrizione": "Missione aerea",
        "nome": "New Mombasa",
        "location": "Bari"
      },
      "equipments": {
        "radio": "no radio",
        "drone": "UAV",
        "minerobot": "no robot",
        "binoculars": "binoculars"
      },
      "weapons": {
        "gun": "Beretta",
        "machinegun": "Heavy Machine Gun",
        "rocketlauncher": "",
        "bombs": "granades",
        "shotgun": ""
      },
      "crew": {
        "team": "Team Bravo",
        "agent": ""
      },
      "veicles": {
        "car": "4x4",
        "submarine": "",
        "jet": "f-16",
        "ship": ""
      }
    }

这是生成模态对话框的部分

    <script type="text/ng-template" id="myModalContent.html" >
        <div class="modal-content">
            <div class ="modal-header">
                <h3 class ="modal-title">Dettaglio Missione {{Items.nome}}{{Items.mission.nome}} Codice:{{Items.codice}}{{Items.mission.codice}}</h3>
            </div>

            <br>

            <div class="bs-example bs-example-tabs">
                <ul id="myTab" class="nav nav-tabs">
                    <li class="" ng-repeat="(key, value) in Items"><a href="#{{key}}" data-toggle="tab">{{key}}</a></li>
                </ul>
            </div>

            <div class="modal-body">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade in" ng-repeat="(key, value) in Items" id="{{key}}">

                            {{value}}

                    </div>
                </div>

            <div class="modal-footer">
            <button class="btn btn-primary" type="submit" ng-click="ok()">OK</button>
            <button class="btn btn-warning" type="submit" ng-click="cancel()">Cancel</button>
            </div>
        </div>
    </script>

在照片中有结果,如您所见,选项卡正确显示,但是{{value}}显示所有json,而不仅显示值。

最佳答案

替换{{value}}


{{value.gun}}
{{value.machinegun}}
{{value.rocketlauncher}}
{{value.bombs}}
{{value.shotgun}}


或替换为循环:

<div class="type" ng-repeat="(k, v) in value">
    {{k}}:{{v}}
</div>

10-07 19:58
查看更多