Search code examples
angularjsmomentjsangular-moment

Printing momentjs object within angular templates


I am trying to print momentjs object not ISO8601 string within angularjs templates.

let's say I have something i.e

$scope.time = moment();

and in my template when I do the following

<span ng-bind="time"></span> or <span>{{time}}</span>

I guess what I am trying to do is to avoid calling momentjs toString() or .toJSON() object which might be triggers by {{}}, however, I do not want to override those function that are chained onto moments prototype.


Solution

  • <span ng-bind="demo.$time.toObject()|json"></span>

    http://momentjs.com/docs/#/displaying/as-object/