显示星期几

时间:2014-04-19 09:07:12

标签: angularjs angularjs-ng-repeat

我在模板中显示星期几,我在控制器中声明了

$scope.weekday = new Array(7);
        $scope.weekday[0]="Sunday";
        $scope.weekday[1]="Monday";
        $scope.weekday[2]="Tuesday";
        $scope.weekday[3]="Wednesday";
        $scope.weekday[4]="Thursday";
        $scope.weekday[5]="Friday";
        $scope.weekday[6]="Saturday";

由于我是棱角分明的新手,想问一下是否可以,或者我可以优化它。

2 个答案:

答案 0 :(得分:2)

你可以这样写得更好。

$scope.weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

答案 1 :(得分:0)

使用$ local object:

检查一下
$locale.DATETIME_FORMATS.DAY