Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

ng-engineer/angular-momentjs

 
 

Repository files navigation

angular-momentjs Build Status

Moment.js with Angular.js

#How do I add this to my project?

You can download angular-momentjs by:

<body ng-app="YOUR_APP" ng-controller="MainCtrl">
 {{ time }}
  or
 {{ anotherTime }}
</body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script src="app/bower_components/angular-momentjs/angular-momentjs.js"></script>
<script>
  angular.module('YOUR_APP', [
    'angular-momentjs',
    'controllers'
  ]);
  
  angular.module('controllers', [])
    .controller('MainCtrl', ['$scope', '$moment', function($scope, $moment) {
      // if you include momentjs script above
      $scope.time = $moment("20111031", "YYYYMMDD").fromNow();
      
      // if you don't include momentjs script then angular-moment will inject the script 
      $moment.promise.then(function(t) {
        $scope.anotherTime = t("20111031", "YYYYMMDD").fromNow();
      })
    }]);
</script>

About

Moment.js with Angular

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors