javascript - Please give me some guidance. Angular's $event is undefined in select?
世界只因有你
世界只因有你 2017-06-05 11:09:56
0
2
729

Development environment:

  • angular 1.6.1

  • Chrome latest version

Development issues:

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

Development purpose:

  • 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?

DEMO:

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

Screenshot description:

  • angular

  • JavaScript


Thank you very much for helping me check and answer. Thank you.

世界只因有你
世界只因有你

reply all(2)
伊谢尔伦

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

淡淡烟草味

Answer here: https://stackoverflow.com/que...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template