How does angular2 pass the properties of the current component to the native click event?

The normal click event in

angular2 is: (click) = "selectClass (classItem)", and classItem is a property in the current component, which is fine, but now you need to use native click events such as: onclick= "routerTo ()". How to pass the properties of the current component to this function?

Mar.04,2021

I really don't know what circumstances force you to use native onclick events.


angular belongs to the js framework and must be used in full. The original way to write it depends on how the source code of angular is written, otherwise your routerTo method will not be able to get it, right? There must be some rules when the framework gets the data, just like the selector, if you use the class selector in the source code and you use the Id tag, it certainly won't get it. -- in a general sense, angular has not learned much, and has not found a solution for the time being


you need to get NativeElement and add subscription events to it. For more information, please see https://codeshelper.com/a/11.

.
Menu