how to pass angular js variable inside onclick function as parameter

前端 未结 9 1641
一生所求
一生所求 2020-12-15 20:37

I have tried to pass AngularJS variable as argument value inside onclick() to call javascript function. Can anyone guide me on how to do it?

My code:

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 21:11

    You are not allowed to create a binding for event handler attributes like onclick, onload, onsubmit, etc. in angularjs because, there is no practical value in binding to these attributes and doing so it only exposes your application to security vulnerabilities like XSS. For these reasons binding to event handler attributes (all attributes that start with on and formaction attribute) is not supported in angularjs.

    For your case,

    Inside ng-repeat, use ng-click for sending values to your function and declare that function in controller.

    See here for documentation of ng-click

    Hope this helps !

提交回复
热议问题