我正在更新angularjs中的表单,其中一个字段是加入日期
我想显示从数据库加入到字段的日期的当前值,但是当我使用输入类型date
时,该值不显示
但是当我将类型更改为text
时,会显示该值。
我的问题是,如何使用date_joined
显示和更新type=date
?
编辑: 这是代码:
HTML:
<label class="item item-input item-stacked-label">
<span class="input-label">
<b>Date Joined:</b>
</span>
<input type="text" ng-model="memUpdate.date_joined" ng-value="memDataViaId.date_joined"></input>
</label>
我正在使用SQLite。
这是我在JS中的查询:
var query = "SELECT members.*, branches.name as branch_name, branches.id as branches, branches.name as branch_name, "
+ "groups.name as group_name, groups.id as groups, civil_statuses.name as civil_status_name, "
+ "civil_statuses.id as civil_statuses, religions.id as religions, educations.id as educations, "
+ "mem_join_resigns.date_joined as date_joined, .....
答案 0 :(得分:0)
在控制器中注入$filter
服务,然后像这样使用
$filter("date")(myDate, 'yyyy-MM-dd');
这里,语法myDate
是来自数据库的日期。
工作演示:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope, $filter) {
var myDate = '2010-10-29T00:00:00';
$scope.date = $filter("date")(myDate, 'yyyy-MM-dd');
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="MyCtrl">
<input type="date" ng-model="date">
</div>
</body>