有没有一种方法可以将日期选择器值添加到Firebase数据库中?
遵循这些原则?
$scope.AddPost = function() {
...
Published: $scope.post.Published.DATESTAMP
...
}
来自实现日期选择器值,如下所示:
<input type="date" ng-model="post.Published" class="datepicker">
选择器中的服务器端代码:
<input type="text" ng-model="post.Published" class="datepicker ng-pristine ng-valid picker__input ng-touched picker__input--active picker__input--target" readonly="" id="P2078770150" tabindex="-1" aria-haspopup="true" aria-expanded="true" aria-readonly="false" aria-owns="P2078770150_root">
尝试:
$scope.AddPost = function() {
myPosts.$add({
Title: $scope.post.Title,
Intro: $scope.post.Intro,
Body: $scope.post.Body,
Published: $scope.post.Published,
Author:$scope.post.Author
})
除日期外,所有内容均加载。
我一直在寻找一个等价的商品,但只发现了Firebase.ServerValue.TIMESTAMP
那不是我想要的商品,因为我需要人们能够手动选择日期。
我设法通过各种线程来解决此问题。所以我
的HTML
<div class="form-group">
<label class="col-md-4 control-label" for="numDate">Choose a Date</label>
<input type="date" name="Published" ng-model="post.Published" class="datepicker" required>
<span class="error" ng-show="input.Published.$error.required">
</div>
在AddPost()函数中:
Published: new Date($scope.post.Published).getTime(),
角度
<p>By: {{post.Author}} Published on: {{post.Published | date:'mediumDate'}}</p>
因此,我没有尝试在添加过程中进行转换,而是保留了一个时间戳,然后在视图中对其进行了转换。
谢谢
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句