前端之家收集整理的这篇文章主要介绍了
angularjs中日期的回显,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--
日期的回显问题:在你编辑用户信息的时候,从后台取到的数据显示在浏览器上。
-->
<script>
angular.module("myApp",[]).controller("myControl",["$scope",function($scope){
$scope.filter = {
'start_date':'','end-date':''
};
$scope.filter.start_date = '2016-12-12'; //假如这是后台传过来的数据
$scope.filter.end_date = '2016-12-13';
//alert($scope.filter.start_date);
$scope.filter.start_date = new Date($scope.filter.start_date);
$scope.filter.end_date = new Date($scope.filter.end_date);
}]);
</script>
</head>
<body ng-app="myApp" ng-controller="myControl">
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<div class="input-group input-large date-picker input-daterange" data-date="2012-10-11" data-date-format="yyyy-mm-dd">
<input type="date" class="form-control" name="from" ng-model="filter.start_date" >
<span class="input-group-addon"> 至 </span>
<input type="date" class="form-control" name="to" ng-model="filter.end_date" >
</div>
</div>
</div>
</div>
</body>
</html>
原文链接:https://www.f2er.com/angularjs/146616.html