1
I would like to make a frame with Angularjs data
Populating of the data via json so:
Example: date = ""01/01/2015" but, will be shown only the day
The table is made with a loop
<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 }}
Doing it in Angular is not so easy. Better before turning your data into an array, and so use two ngRepeat, one for the columns and one for the rows. What you tried?
– Vinícius Gobbo A. de Oliveira
But, I would like to manipulate the data with ng-click for example. Will I have to create a single data type: {{ calendario.id01.data01 }}, {{ calendario.id02.data02 }}, etc
– Luis Souza
Apparently you’re looking to set up a calendar, correct?
– celsomtrindade
Yes, it’s a calendar
– Luis Souza
Well, with Angularjs, at least I don’t know, a dynamic method of filling in calendar format. But there are some calendars for Angularjs out there, take a look at this one: http://angular-ui.github.io/ui-calendar/
– celsomtrindade