Loop with AngularJS data

1

I would like to make a frame with AngularJS data

Populatingthedataviajsonlikethis:

Example:date="" 01/01/2015 "but, the will only be shown the day

The table is looped

    <div ng-app="myApp" ng-controller="myCtrl">

<table class="table table-striped" border="1">

<?php
echo "<tr>";
$diadasemana = date("w", mktime(0, 0, 0, $mes, 1, $ano));
$total = 35 - $diadasemana;

if (($diadasemana == 0) and $dias == 28)
    {
    $total = 28;
    }

for ($i = 1; $i <= $total; $i++)
    {
    $diadasemana = date("w", mktime(0, 0, 0, $mes, $i, $ano));
    $cont = 0;
    if ($i == 1)
        {
        while ($cont < $diadasemana)
            {
            echo "<td></td>";
            $cont++;
            }
        }

    echo "<td><center>";
?>
 <div> <?php
    echo $i; ?></div>
<?php
    echo "</center></td>";
    if ($diadasemana == 6)
        {
        echo "</tr>";
        echo "<tr>";
        }
    }

echo "</tr>";
?>

</table>
 </div>

The json data

[
  {
    "id":1,
    "ano_letivo":2016,
    "escola_cod":"31011975",
    "dia":"01/01/2016",
    "situacao":"feriado"
  },
  {
    "id":2,
    "ano":2015,
    "escola_cod":"31011975",
   "dia":"02/01/2016",
    "situacao":"recesso"
  },
  {
    "id":3,
    "ano":2015,
    "escola_cod":"31011975",
    "dia":"03/01/2016",
    "situacao":"recesso"
  },
  {
    "id":4,
    "ano":2015,
    "escola_cod":"31011975",
   "dia":"04/01/2016",
    "situacao":"dia letivo"
  }
]

the variable $ i should be {{dia}}

    
asked by anonymous 15.11.2015 / 03:03

1 answer

0

Would that be?

var app = angular.module("App", []);
app.controller("AppController", function($scope){
    $scope.xxx = [
        {
            "id":1,
            "ano_letivo":2016,
            "escola_cod":"31011975",
            "dia":"01/01/2016",
            "situ  acao":"feriado"
        },
        {
            "id":2,
            "ano":2015,
            "escola_cod":"31011975",
            "dia":"02/01/2016",
            "situacao":"recesso"
        },
        {
            "id":3,
            "ano":2015,
            "escola_cod":"31011975",
            "dia":"03/01/2016",
            "situacao":"recesso"
        },
        {
            "id":4,
            "ano":2015,
            "escola_cod":"31011975",
            "dia":"04/01/2016",
            "situacao":"dia letivo"
        }
    ];
});

app.filter('xxxFilter', function() {
    return function(input) {
        var output = input.indexOf('-') > -1? input.split('-')[2] : input.split('/')[0];
        return output;
    };
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="App" ng-controller="AppController">
    <ul ng-repeat="x in xxx">
        <li><input type="date" ng-model="x.dia"/></li>
        <li>{{x.dia | xxxFilter}}</li>
    </ul>
</div>
    
15.11.2015 / 03:46