我只需要在输入中显示日期和月份,我已经离开了,但在处理之内只需获取完整日期。
<input type="date" ng-model="someDate">
<p>{{someDate | date:'dd MMMM'}}</p>
在我的控制器中
mainAppControllers.controller('DoarScanCtrl', ['myservice','$rootScope','$scope', '$routeParams', '$location','$timeout','$filter',
function(myservice, $rootScope, $scope, $routeParams, $location,$timeout ,$filter){
$scope.someDate = new Date();
答案 0 :(得分:1)
您可以使用watch
模型值并在更改时进行更新。
app.controller('MainCtrl', function($scope,$timeout) {
$scope.dateObj = new Date();
$scope.$watch('someDate', function() {
var month = $scope.dateObj.getUTCMonth() + 1; //months from 1-12
var day = $scope.dateObj.getUTCDate();
$scope.someDate = month + "/" + day;
});
})
并在您的模板中
<input ng-model='someDate' ng-trim='false'/>
<p>{{someDate}}</p>
<强> See my Working Jsfiddle 强>