I had to use the type field for the date input as hidden so the date is a
string in this format:2016-04-22T19:10:31.064Z
I need to make a date calculation and get the seconds for the expression
message below. How do I get the seconds from the string?
I don't know how to make a date filter.
angular.module('commentForm', [])
.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" ng-model="comment.date" name="date"
value="{{comment.date}}"/>' +
'<p>{{comment.date }}</p>'+
'<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.date = new Date();
if (!comment.msg || !comment.author) {
return;
}
scope.$emit('submitted', comment);
scope.comment = {};
}
}
};
});
-----------
'<span>{{ comment.seconds < 59 && ("Updated 1 minute ago") }}</span>'+
'</div>',
--
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.