urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

`isSameOrBefore` is not a function #287

Open atefBB opened 7 years ago

atefBB commented 7 years ago

Hey, I used moment before (without AngularJs) and I used the isSameOrBefore() function and It works, but when I use Angular-moment module it raise this error : $scope.moment_var.isSameOrBefor is not a function. Have you any ideas?

shani7783 commented 6 years ago

Hey, It's usually happened while you don't have really an object of moment, it's probably a string, You should first create an object of moment and then you can use it. for example: const myMomentDate: moment.Moment; let strDate: string = "2017-11-30T00:00:00" myMomentDate = moment.utc(strDate);

strDate is a string that represent date so the moment's functions are not exposed of course. Now for myMomentDate you can use isSameOrBefore() without getting any exception.

atefBB commented 6 years ago

Thanks @shani7783 !