以下是代码:
<div ng-app="myApp" ng-controller="myCtrl">
<input type="date" ng-model="fromDate" />
<input type="date" ng-model="toDate" />
<input type="number" ng-value="difference(fromDate, toDate)">
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.difference = function (fromDate, toDate) {
if (fromDate && toDate) {
return Math.round(Math.abs((new Date(fromDate).getTime() - new Date(toDate).getTime())/(24*60*60*1000)));
}
}
});
</script>
y轴看起来很烦人,那怎么能把它放在我的图表左侧?