Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get $event from ng-click or ng-change in Firefox #13628

Closed
kevin031612 opened this issue Dec 25, 2015 · 2 comments
Closed

Cannot get $event from ng-click or ng-change in Firefox #13628

kevin031612 opened this issue Dec 25, 2015 · 2 comments

Comments

@kevin031612
Copy link

@kevin031612 kevin031612 commented Dec 25, 2015

When I used ng-change or ng-click to listen a checkbox, the function can not get the event( whether I pass $event or not). The code is :
HTML

<input type="checkbox" ng-change="SendList.oListen.fnCheckHead($event)" ng-model="SendList.oListen.checkHead[career.career_id]" />

JS

   $scope.SendList.oListen.fnCheckHead:function(ev){
                var oEvent = ev||window.event;             //ev=>undefined, oEvent=>undefined
                var self = oEvent.target||oEvent.srcElement;
            }

And when i use onclick and onchange without angularJS, I can easily get the event by passing the parameter "event".
So please tell me how to get the event of ng-* in Firefox.
Thank you.

@wesleycho
Copy link
Contributor

@wesleycho wesleycho commented Dec 25, 2015

ng-change is not an evented directive - one cannot get the event from there. It is an expression that is executed when the model changes from a view value change.

One needs to write a custom directive listening for the input/change event on the element itself in order to do this.

@Narretz
Copy link
Contributor

@Narretz Narretz commented Dec 31, 2015

@wesleycho is right. Thanks for answering!

@Narretz Narretz closed this Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.