angular 1.6.1
Chrome latest version
I want to use $event to get the object of the event operation, but it is undefined in the select, which is very confusing.
Due to the maintenance requirements of old projects, I have just come into contact with angular, but I have not had time to study it in depth. I hope that familiar friends can give me some guidance.
You need to get the event itself in angular's select, and then use .target to get the DOM of the operation.
Why does undefined appear?
In order to trace the source, I used angular and native js to obtain the event itself.
CODEPEN DEMO
Due to codepen’s limitations on console output, the picture below shows my implementation.
angular
JavaScript
Thank you very much for helping me check and answer. Thank you.
伊谢尔伦2017-06-05 11:11:56
ng-change does not allow passing $event, because it is not an event in angular, but listens for changes in values, so there will be no $event.
Do you have any need to operate the dom?
About angular, please explain:
1. If you use angular, try not to directly operate the dom
2. If you really need to operate, it is best to operate with a directive