It loads the momentModule with the other directives now!!! It was grunt 
serve issue with the build.  Now  I need to inject $window.moment into this 
form .  The $window.moment (date) value should be input into the hidden 
value of the input because I want to store the value in a mongo db.  
 I am getting the error:commentform.js:9 Uncaught ReferenceError: $window 
is not defined
It doesn't like how I injected it.  The reason i'm doing it this way 
instead of  defining a moment.time on a new Date() is I want it at the 
$rootscope not after comment.moment .  I need scope.moment for the moment 
module to work.  So if this window injection thing would work,I'd be home.
-------------------

angular.module('commentForm', [$window.moment])
  .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.dateCreated" name="date" 
value="{{$window.moment}}"/>' +
      '{{comment.dateCreated  }}'+

      '<input type="hidden" ng-model="comment.dateCreated" name="date" />' +

       '<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 Sunday, April 24, 2016 at 8:49:25 PM UTC-7, Sander Elias wrote:
>
> Hi Janis,
>
> You should add 'moment-module' to your angualrApp module's module array. 
> From that moment on, it's available to the injector, and can you inject it 
> where ever you need it.
>
> Regards
> Sander
>

-- 
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.

Reply via email to