【发布时间】:2016-10-20 22:29:17
【问题描述】:
我想将在我的 datepicker 输入中选择的日期发送到一个 php 变量,但我不知道如何在没有 angularJS 中的“提交”表单按钮的情况下执行此操作(以避免重新加载页面)。
我试过了,但没有成功:
我的php代码:
<?php
require('config-bd.php');
$filtros = json_decode(file_get_contents("php://input"));
$fec1 = $filtros->fec1;
$fec2 = $filtros->fec2;
?>
我的html代码:
<div class="form-group">
<label for="desde" style="margin-left: 5px;">Desde:</label>
<div class="input-group">
<input name="fec1" type="text" class="form-control input-sm" uib-datepicker-popup ng-model="dt1" is-open="popup1.opened" datepicker-options="dateOptions" close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-sm" ng-click="open1()"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
<div class="form-group">
<label for="hasta" style="margin-left: 5px;">Hasta:</label>
<div class="input-group">
<input name="fec2" type="text" class="form-control input-sm" uib-datepicker-popup ng-model="dt2" is-open="popup2.opened" datepicker-options="dateOptions" close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-sm" ng-click="open2()"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
和我的控制器代码:
$scope.today = function() {
$scope.dt1 = new Date();
$scope.dt2 = new Date();
};
$scope.today();
$scope.clear = function() {
$scope.dt1 = null;
$scope.dt2 = null;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.open1 = function() {
$scope.popup1.opened = true;
};
$scope.open2 = function() {
$scope.popup2.opened = true;
};
$scope.setDate = function(year, month, day) {
$scope.dt1 = new Date(year, month, day);
$scope.dt2 = new Date(year, month, day);
};
$scope.popup1 = {
opened: false
};
$scope.popup2 = {
opened: false
};
提前感谢:)
【问题讨论】:
-
用php创建一个rest api并使用angular的
$http
标签: php html angularjs variables input