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?
use ng-click="switchLanguage(language.value)"
Here is the PLUNKER: http://plnkr.co/edit/uOUD9f1P3tKp3IlGsjBK?p=preview
Instead of
<a ng-click="switchLanguage('{{language.value}}')" >Translate</a>
Use this
<a ng-click="switchLanguage(language.value)" >Translate</a>
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