month=[1,2,3,4,5,6,7,8,9]
這是從服務器獲取的數組。如何獲得月份名稱?如何從月份數中獲取月份名稱
直到現在我嘗試這樣做:
var populateChartData = function (data) {
var getMonth = [];
var getProfit = [];
$scope.chartTitle = 'Year :' + moment().year();
data.forEach(function (obj) {
console.log(obj.month);
getMonth.push(moment().month(obj.month).format('MMM'));
});
console.log(getMonth);
};
但在控制檯我得到
["Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"]
我應該得到這樣
["Jan","Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"]