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, {{user.email}})">Get it Done</button>
foo
is a function in a controller, bar
and fruits
are values from a form and {{user.email}}
is an email in scope.
I could get {{user.email}}
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.
$scope.foo = function(bar, fruits, email) {
//email is undefined here
};
Could somebody help me understand how could I pass that {{user.email}}
value to the foo
function in the controller?
Please see here http://jsbin.com/mawey/1/edit. You don't have to interpolate user.email
just:
<button type="button" class="btn" ng-click="foo(bar, fruits, user.email)">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With