You are re-posting it as just 'event', not '$event'... your also passing 2
objects to the "inject-able function". so you should either correct your
directive template to:
"*ng-keyup='postComment( { event: $event, comment: comment} )'* then
consume it as *post-comment="moduleService.postComment(event, comment)"*
or
"*ng-keyup='postComment( { $event: $event, comment: comment} )'*
On Saturday, July 19, 2014 9:54:11 PM UTC+2, Diego Freitas wrote:
>
> Hey guys,
>
> I've been facing a problem to build a module for me.
>
> I have this structure:
>
> *Calling my directive *- passing a postComment function that is inside
> the moduleService which is inside the controller
>
>> <div input-directive class-name="globalInput"
>> *post-comment="moduleService.postComment($event,
>> comment)"* msg-placeholder="Redija um comentario..."
>> class="mainComment"></div>
>
>
> *Directive*
>
>> .directive('inputDirective', function(){
>> return {
>> restrict: 'A',
>> scope: {
>> postComment: '&',
>> msgPlaceholder: '@',
>> className: '@'
>> },
>> template: "<textarea ng-model='comment' class='{{className}}'
>> placeholder='{{msgPlaceholder}}' "+
>> "*ng-keyup='postComment( {event: $event}, {comment: comment} )'*
>> ></textarea>"
>> };
>> });
>
>
> When the function is called I can see the comment object - but the event
> is undefined.
>
> *Service*
>
>> this.postComment = function(*event*, *comment*){
>> //EVENT IS UNDEFINED
>> }
>
>
> Does anybody know what is happening?
>
> Thanks in advance !
>
--
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 http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.