0

I have this jQuery function:

   function updateProfile(profile, sessionId){
    alert(profile,sessionId);
}

In HTML I have like this

<button onclick="updateProfile(profile, {{sessionId}})">Update</button>

It doesn't work since the {{sessionId}} is the angularjs variable.

What is the correct way to pass this angularjs variable inside the jquery onclick function?

Thank you all for participating!

DuliNini
  • 181
  • 2
  • 14
  • Possible duplicate of [how to pass angular js variable inside onclick function as parameter](https://stackoverflow.com/questions/32377632/how-to-pass-angular-js-variable-inside-onclick-function-as-parameter) – 4b0 Mar 02 '18 at 11:29
  • I saw that answer, but mine is a bit different because I must use the onclick for a jquery function and the ng-click for angularfunction ONCLICK is for updates on the table (but does not send update on servers) NG-CLICK has some other params that sends to the server – DuliNini Mar 02 '18 at 11:31
  • @DuliNini you [should avoid using jQuery](https://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background) in the first place. It is used for DOM manipulations which angularjs does with directives (that use jQLite) – Aleksey Solovey Mar 02 '18 at 11:43

1 Answers1

0

Use ng-click instead of onclick and define your function in your scope

//HTML
<button ng-click="updateProfile(profile, {{sessionId}})">Update</button>

//Angular
$scope.updateProfile = function(profile, sessionId){
    alert(profile,sessionId);
}
  • Not what I mean exactly. Well I want to have onclick instead of ng-click So this is a jquery function not an angular function – DuliNini Mar 02 '18 at 14:03