Pass a dynamic value to a function in angular with ng-click

Viewed 8724

I'm trying to use a link to dynamically translate a website.

This is my HTML:

<a  ng-click="switchLanguage('{{language.value}}')" >Translate</a>

{{language.value}} is a dynamic value taken from a json file and I can verify that upon runtime, it does get populated with the proper value ('en-us','ja-jp', etc...)

And here's my function inside a controller:

function switchLanguage(newlan) {
    console.log(newlan);
}

However, everytime I click on the link, the console shows the value as {{language.value}}, instead of the proper value (ex: en-us).

How do I make the value inside the ng-click pass the correct parameter to the function?

3 Answers
Related