I have a hidden input field called comment.dateCreated gets entered into
the database. I can't figure out how to use momentModule with it.
for example, time ago is what I want to use. <span am-time-ago="message.time
"></span> but how do I get the comment.dateCreated = message.time? It
seems the am-time-ago only works with message.time not the field I have
saved.So as I envision it am-time-ago keeps changing based on time elapsed
but it has to compare with my comment.date created field because that one
is based on the data model structure other wise I don't know how to change
the data model in order to accomodate message.time???? In other words <span
am-time-ago="comment.dateCreated"></span> doesn't work.
--comment form----
angular.module('commentForm', ['momentModule'])
.directive('commentForm', function () {
return {
template: '<form class="commentForm" name="form">' +
'<input type="text" placeholder="Your name"
ng-model="comment.author" name="author"/>' +
'<input type="text" placeholder="Say something..."
ng-model="comment.msg" name="msg"/>' +
'<input type="hidden" name="date"
ng-model="comment.dateCreated" ng-value="{{comment.dateCreated}}"/>' +
//'<span am-time-ago="comment.dateCreated"></span>'+
'<span am-time-ago="message.time"></span>' +
'<input type="submit" value="Post"
ng-click="submitComment()"/>' +
'</form>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
scope.comment = {};
scope.submitComment = function(){
var comment = scope.comment;
comment.dateCreated = new Date();
if (!comment.msg || !comment.author) {
return;
}
scope.$emit('submitted', comment);
scope.comment = {};
}
}
};
});
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.