日期相关小时角度

时间:2017-12-13 16:04:08

标签: javascript angularjs multidimensional-array

大家好我想做的是收集我输入其中一个输入的日期,然后用它从我的数据库收取小时数:create.html

<div class="form-group">
    <label for="fechaInicio">Fecha de la cita:</label>
        <div class="input-group date fecha">
    <input type="text" name="fechaInicio" class="form-control" id="fechaInicio" ng-model="cita.fechaInicio"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>

将其传递给控制器​​:控制器。 JS:

$scope.getHoras = function(){
        var fechaInicio = fechaInicio;
        $http.get('../api/horas.php'),{'fechaInicio':fechaInicio}.then(function(response){
            $scope.citas = response.data;
        });
    };

进行查询:hours.php:

<?php
$data = json_decode(file_get_contents("php://input"));
@session_start();
$id = $_SESSION["user_id"];
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "pruebas";
$conn = new mysqli($servername, $username, $password, $dbname);
/*$sql = "SELECT hora FROM horas where $fecha and horaCompleta = '1'"*/
$sql = "SELECT hora FROM citas WHERE horaCompleta = 0 AND 'fechaInicio = $date-> fechaInicio' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
     $data = array() ;
    while($row = $result->fetch_assoc()) {
        $data[] = $row;

    }
} else {
    echo "0 results";
}
echo json_encode($data);
$conn->close();
?>

现在查看在create中收集的数据。我的选择字段上的HTML:

 <div class="form-group">
      <label for="hora" ng-init="getHoras()">Hora:</label>
<select ng-model="cita.hora">

<option
value="{{cita.hora}}"
ng-repeat="cita in citas">
{{cita.hora}}
</option>
</select>

问题是我想根据我在上面的Imput中选择的日期来显示可用的小时数。

可视化: visualization horas - &gt;小时 fecha de la cita - &gt;日期

0 个答案:

没有答案