1、获取当前时间
$scope.today = new Date();
2、转化为字符串
首先要引入$filter,然后调用filter的方法
$scope.timeString = $filter('date')($scope.today, 'yyyyMMddHHmmss');3、完整代码如下:
.controller('myController',['$scope','$filter',function ($scope,$filter) { $scope.today = new Date(); $scope.timeString = $filter('date')($scope.today, 'yyyyMMddHHmmss'); }]);