I'm just adding the angularMoment plgin to the app. How do I write the
diective?
Basically these scripts need to get referenced the angular way but how? thanks,
<script src="components/moment/moment.js"></script>
<script src="components/angular-moment/angular-moment.js"></script>
angular.module('commentForm', ['angularMoment'])
.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>'+
'<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.date = new Date();
if (!comment.msg || !comment.author) {
return;
}
scope.$emit('submitted', comment);
scope.comment = {};
}
}
};
});
--
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.