How to pass interpolated value as an argument into a javascript function in angularjs


I call a function when a button is clicked in html in my angularjs app like below

<button type="button" class="btn" ng-click="foo(bar, fruits, {{}})">Get it Done</button>

foo is a function in a controller, bar and fruits are values from a form and {{}} is an email in scope.

I could get {{}} displayed on the html page alright, but I get an undefined for it in the foo function of the controller, when the given button is clicked.

$ = function(bar, fruits, email) {
    //email is undefined here

Could somebody help me understand how could I pass that {{}} value to the foo function in the controller?


Please see here You don’t have to interpolate just:

<button type="button" class="btn" ng-click="foo(bar, fruits,">

Answered By – sylwester

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published