The factory injected 'moment'
didn't work but I got it to work by injecting 'momentModule' ?? I guess it
injected the whole module? don't know but I do have a moment object so it
worked in the input form module. But originally I had the momentModule as
one of the 4 directives to run by the .run method. might have something
to do with it. So I took that out and didn't run momentModule. I tried it
every which way. Finally just injecting it as a momentModule into where I
need it works not just as 'moment' which theoretically seems right . I
have no idea what is happening with the $window or global or whatever but
it does see a moment value in the console.window so some part of the module
is available that way.
Now all I need the am-time-ago '<span
am-time-ago="comment.dateCreated"></span>'+
to work, trouble is it doesn't work. To compare the comment.date.created
to the current time and tell me how long since it was updated. In the
commentform directive, I create a moment var named comment.dateCreated. It
is input into the database. I just need to compare that value with now.
Do I have to create another moment for some reason in this directive.
This comment list just displays the values from the form. thanks very much
for your help even if I don't get this I really learned a lot about
angular.
angular.module('commentList', ['comment','momentModule'])
.directive('commentList', function () {
return {
template: '<div class="commentList">' +
'<comment-model ng-repeat="comment in comments"
author="{{comment.author}}">' +
'{{comment.msg}}' +' '+' '+
'{{comment.dateCreated | date: "MM-dd-yyyy"}}
'+' '+' '+
'<span am-time-ago="comment.dateCreated"></span>'+
'</comment-model>' +
'<span ng-if="comments.length < 1">No comments yet</span>' +
'</div>',
restrict: 'E',
scope: {
comments: '='
},
link: function postLink(scope, element, attrs) {}
};
});
On Monday, April 25, 2016 at 9:28:17 PM UTC-7, Sander Elias wrote:
>
> Your factory is called 'moment', so inject that, and not '$windows.moment'
> .
>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.