2

Доброго времени.Не смог найти ответ на мою задачу. Есть Json вида

[
  {
    "code": "1",
    "name": "Шиленко Кристина",
    "score": "84000",
    "doc" : "top"
  },
  {
    "code": "2",
    "name": "Колесникова Кристина",
    "score": "4975593",
    "doc" : "sob"
  },
  {
    "code": "3",
    "name": "Мокеева Юлия",
    "score": "29121286",
    "doc" : "old"
  },
  {
    "code": "4",
    "name": "Канапацкая Оксана",
    "score": "86754",
    "doc" : "old"
  },
  {
    "code": "5",
    "name": "Саблина Алена",
    "score": "13254",
    "doc" : "sob"
]

Нужно выводить только данные с атрибутом "top"

Выводится в html:

<!doctype html>
<html ng-app="CupApp">
<head>
<meta charset="utf-8">
<title>Главная</title>
<meta name="author" content="Бородин Дмитрий">
<link href="Безымянный1.css" rel="stylesheet">
<link href="Rating.css" rel="stylesheet">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
 <script>
  var CupApp = angular.module('CupApp', []);
  CupApp.controller('CupCtrl', function ($scope, $http){
    $http.get('cup.json').success(function(data) {
      $scope.cups = data;
    });
  });
 </script>
</head>
<body ng-controller="CupCtrl">
<div id="container">
<div id="wb_Shape1" style="position:absolute;left:0px;top:51px;width:800px;height:1100px;filter:alpha(opacity=60);opacity:0.60;z-index:0;">
<img src="images/img0001.png" id="Shape1" alt="" style="width:800px;height:1100px;"></div>
<div id="wb_Image5" style="position:absolute;left:7px;top:97px;width:251px;height:37px;z-index:1;">
<img src="images/admos-logo-master.png" id="Image5" alt=""></div>
<div id="Html1" style="position:absolute;left:9px;top:180px;width:778px;height:957px;z-index:2">
<h2>Топ в компании</h2>
  <table class="table table-striped">
   <tr>
    <th>Место</th>
    <th>Менеджер</th>
    <th>Балы</th>
   </tr>
   <tr ng-repeat="cup in cups | orderBy: 'code' ">
    <td>{{cup.code}}</td>
    <td>{{cup.name}}</td>
    <td>{{cup.score}}</td>
   </tr>
  </table>

</div>
<div id="wb_CssMenu2" style="position:absolute;left:304px;top:80px;width:483px;height:70px;text-align:center;z-index:3;">
<ul>
<li class="firstmain"><a href="./index.html" target="_self" title="&#1050;&#1072;&#1082; &#1101;&#1090;&#1086; &#1088;&#1072;&#1073;&#1086;&#1090;&#1072;&#1077;&#1090;">&#1050;&#1072;&#1082;&nbsp;&#1101;&#1090;&#1086;&nbsp;&#1088;&#1072;&#1073;&#1086;&#1090;&#1072;&#1077;&#1090;</a>
</li>
<li><a class="withsubmenu active" href="./Rating.html" target="_self" title="&#1056;&#1077;&#1081;&#1090;&#1080;&#1085;&#1075;&#1080;">&#1056;&#1077;&#1081;&#1090;&#1080;&#1085;&#1075;&#1080;</a>

<ul>
<li class="firstitem"><a class="active" href="./Rating.html" target="_self" title="&#1058;&#1054;&#1055; &#1074; &#1082;&#1086;&#1084;&#1087;&#1072;&#1085;&#1080;&#1080;">&#1058;&#1054;&#1055;&nbsp;&#1074;&nbsp;&#1082;&#1086;&#1084;&#1087;&#1072;&#1085;&#1080;&#1080;</a>
</li>
<li><a href="./Sobitiya.html" target="_self" title="&#1057;&#1086;&#1073;&#1099;&#1090;&#1080;&#1103;">&#1057;&#1086;&#1073;&#1099;&#1090;&#1080;&#1103;</a>
</li>
<li><a href="./Vstrechi.html" target="_self" title="&#1042;&#1089;&#1090;&#1088;&#1077;&#1095;&#1080;">&#1042;&#1089;&#1090;&#1088;&#1077;&#1095;&#1080;</a>
</li>
<li><a href="./Old.html" target="_self" title="&#1057;&#1095;&#1077;&#1090;&#1072; &#1090;&#1077;&#1082;&#1091;&#1097;&#1080;&#1084; &#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;&#1084;">&#1057;&#1095;&#1077;&#1090;&#1072;&nbsp;&#1090;&#1077;&#1082;&#1091;&#1097;&#1080;&#1084;&nbsp;&#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;&#1084;</a>
</li>
<li><a href="./New.html" target="_self" title="&#1057;&#1095;&#1077;&#1090;&#1072; &#1085;&#1086;&#1074;&#1099;&#1084; &#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;&#1084;">&#1057;&#1095;&#1077;&#1090;&#1072;&nbsp;&#1085;&#1086;&#1074;&#1099;&#1084;&nbsp;&#1082;&#1083;&#1080;&#1077;&#1085;&#1090;&#1072;&#1084;</a>
</li>
<li class="lastitem"><a href="./Pay.html" target="_self" title="&#1054;&#1087;&#1083;&#1072;&#1090;&#1072; &#1089;&#1095;&#1077;&#1090;&#1086;&#1074;">&#1054;&#1087;&#1083;&#1072;&#1090;&#1072;&nbsp;&#1089;&#1095;&#1077;&#1090;&#1086;&#1074;</a>
</li>
</ul>
</li>
<li><a href="./Rules.html" target="_self" title="&#1055;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;">&#1055;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;</a>
</li>
</ul>
</div>
</div>
</body>
</html>

1
  • Если вам дан исчерпывающий ответ, отметьте его как верный (галка напротив выбранного ответа). 3 окт 2016 в 5:59

1 ответ 1

2

Применить filter:

<tr ng-repeat="cup in cups | orderBy: 'code' | filter:{ doc:'top' }">

живой пример на Plunker

3
  • а менее костыльно ангулярка не позволяет разве? 2 окт 2016 в 0:30
  • @ГончаровАлександр, Что ж здесь костыльного? Просто и из коробки.
    – user207618
    2 окт 2016 в 0:49
  • Огромное спасибо , помогло
    – heymukki
    2 окт 2016 в 6:10

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.