https://github.com/patrickjs/angular-momentjs
Moment.js with Angular
https://github.com/patrickjs/angular-momentjs
Last synced: 4 months ago
JSON representation
Moment.js with Angular
- Host: GitHub
- URL: https://github.com/patrickjs/angular-momentjs
- Owner: PatrickJS
- Created: 2013-09-24T00:21:17.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T06:47:55.000Z (over 8 years ago)
- Last Synced: 2025-09-04T04:34:10.675Z (4 months ago)
- Language: JavaScript
- Size: 386 KB
- Stars: 46
- Watchers: 5
- Forks: 21
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-momentjs [](https://travis-ci.org/gdi2290/angular-momentjs)
Moment.js with Angular.js
#How do I add this to my project?
You can download angular-momentjs by:
* (preferred) Using bower and running `bower install angular-momentjs --save`
* Using npm and running `npm install angular-momentjs --save`
* Downloading it manually by clicking [here to download development unminified version](https://raw.github.com/gdi2290/angular-momentjs/master/angular-momentjs.js)
#Example usage
````html
{{ time }}
or
{{ anotherTime }}
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();
})
});
````