AngularJS get formatted date in ng-model

前端 未结 3 1779
星月不相逢
星月不相逢 2020-12-18 18:38

I have following text input filled by model value in timestamp:



        
3条回答
  •  粉色の甜心
    2020-12-18 19:20

    You can try a filter

    HTML

    
    

    Controller JS

    $scope.$watch('mydateOfBirth', function (newValue) {
        $scope.workerDetail.dateOfBirth = $filter('date')(newValue, 'yyyy/MM/dd'); 
    });
    
    $scope.$watch('workerDetail.dateOfBirth', function (newValue) {
        $scope.mydateOfBirth = $filter('date')(newValue, 'yyyy/MM/dd'); 
    });
    

提交回复
热议问题