Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am working on enhancing a feature of an already deployed application. All the js code is minified and i only can excess html files. I need to call a function on-click of a 'div' which parse some elements and open a new tab with resolved url(url updated with help of parsed elements).

My initial thought is to make a function in a new js file and add link to it on main html page. Evidently the call to function is fine with on click attribute call on the div. But while passing the angular controller parameters it throws error -

<div onclick="jumpToPage({{vm.username}})"></div>

function jumpToPage(user){
    console.log(user);
};

Note - I don't have access to update minified files and i know i can un-minified it but there are lot of files and process is too long.

Please let me know how to resolve/pass parameter to JavaScript function

share|improve this question
    
jumpToPage() is function in angular controller or javascript ? – Loading.. 14 hours ago

It should be onclick="jumpToPage(vm.username)">

If you pass {{vm.username}} it will get evaluted.

e.g. vm.username ="some_name"

so,your controller will get some_name and not referance to vm.username and

it try to search for the same refarance.If it not find then throw exception.

share|improve this answer
    
I am not calling this function in angular controller. So when i pass vm.username it throws exception. vm not found – NewBee 17 hours ago
    
Can u share the html for controller directive – RIYAJ KHAN 17 hours ago

try to use ng-click, when we use ng-click we don't need to use {{}} anymore, since it is automatically bind the model.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.