From 40b2abd03984191348e0ca74bc6c3f21563fc9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20W=C3=A4ngl=C3=B6f?= Date: Fri, 23 Sep 2016 17:30:21 +0200 Subject: [PATCH] Added a DI example to README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 374a585..cdc8cee 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,17 @@ myapp.run(function(amMoment) { }); ``` + +### Use in controller/service/factory +Inject the `moment`-constant into your dependency injection. For example: + +```js +angular.module('fooApp') + .controller('FooCtrl', ['$scope', 'moment', function ($scope, moment) { + $scope.exampleDate = moment().hour(8).minute(0).second(0).toDate(); + }]); +``` + ### am-time-ago directive Use the `am-time-ago` directive to format your relative timestamps. For example: