Skip to content
Moment.js with Angular
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example chore: update moment Feb 5, 2015
lib chore: bump version 0.2.2 Jul 10, 2015
test/spec add report.yml and checkstyle.yml Jan 23, 2014
.gitignore add .gitignore Sep 24, 2013
.jshintignore include .jshintignore Jan 23, 2014
.jshintrc update .jshintrc Jan 28, 2014
.travis.yml add .travis.yml Sep 24, 2013
Gruntfile.js
README.md Minor improvements Oct 1, 2014
angular-momentjs.js chore: bump version 0.2.2 Jul 10, 2015
angular-momentjs.min.js chore: bump version 0.2.2 Jul 10, 2015
angular-momentjs.min.js.map
bower.json chore: bump version 0.2.2 Jul 10, 2015
checkstyle.xml
package.json chore: bump version 0.2.2 Jul 10, 2015
report.xml add report.yml and checkstyle.yml Jan 23, 2014

README.md

angular-momentjs Build Status

Moment.js with Angular.js

#How do I add this to my project?

You can download angular-momentjs by:

#Example usage

<body ng-app="YOUR_APP" ng-controller="MainCtrl">
 {{ time }}
  or
 {{ anotherTime }}
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="app/bower_components/angular-momentjs/angular-momentjs.js"></script>
<script>
  angular.module('YOUR_APP', [
    'angular-momentjs',
    'controllers'
  ]) // you're able to set Default settings
  .config(function($momentProvider){
    $momentProvider
      .asyncLoading(false)
      .scriptUrl('//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js');
  });

  angular.module('controllers', [])
    .controller('MainCtrl', function($scope, $moment) {
      // If didn't set asyncLoading angular-momentjs
      // will assume you provided moment.js
      $scope.time = $moment("20111031", "YYYYMMDD").fromNow();

      // If you set asyncLoading to true then angular-momentjs
      // will inject the script and return a promise
      $moment.then(function(moment) {
        $scope.anotherTime = moment("20111031", "YYYYMMDD").fromNow();
      })
    });
</script>
You can’t perform that action at this time.