如何从angularJS的后端获得特定的日期月份
我希望添加如下内容:
var curMonth = new Date().getMonth();
var monthData = vm.paymentsData[0].date.Date().getMonth();
if (curMonth == monthData) {
console.log ("Same Month");
}
输入错误:
var monthData = vm.paymentsData[0].date.Date().getMonth();
它说:
angular.js:14328 TypeError: vm.paymentsData[0].date.Date is not a function
感谢后端数据
我认为你的代码应该这样写:
var curMonth = new Date().getMonth();
// this maybe a string .. and you cannot call Date() function in that way.
var monthData = vm.paymentsData[0].date;
// Date function should be called this way.
var monData = (new Date(monthData)).getMonth();
if (curMonth == monData) {
console.log ("Same Month");
}