Naz*_*141 1 time html5 date angularjs ionic-framework
我使用ionicframework来构建具有角度的混合应用程序.我有一个带有两个输入框的表单:日期和时间.日期输入的值保存在数据库中:
Tue Mar 24 2015 00:00:00 GMT 0300 (AST)我在Android设备上运行表单时得到这种类型的数据,但我想保存日期简单如:24-04-2015
我尝试了什么
form.html
<form>
<input ng-model="app.date" class="positive" type="date">
<input ng-model="app.time" class="positive" type="time">
<button ng-click="makeApp(app)">send</button>
</form>
Run Code Online (Sandbox Code Playgroud)
controller.js
$scope.makeApp = function (app) {
$http.post("http://www.foo.com/senddata.php?date="+app.date+"&time="+app.time)
.success(function(data){
});
Run Code Online (Sandbox Code Playgroud)
您可以使用Angular的日期过滤器:
myApp.controller('MyController', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.makeApp = function (app) {
var appDate = $filter('date')(app.date, "dd/MM/yyyy");
$http.post("http://www.foo.com/senddata.php?date="+appDate+"&time="+app.time)
.success(function(data){
// success
});
}
}
Run Code Online (Sandbox Code Playgroud)
https://docs.angularjs.org/api/ng/filter/date