0

I am trying to pass a handlebar HTML variable to a scope function using Angular and if I pass using function('{{variable}}'), the value received in the function is literally {{variable}}. If i use function({{variable}}), Angular pitches a fit. Any ideas?

Here is the snippet..

<span ng-repeat="social in model.social_login">
    <button class="btn btn-{{social.network_name}} btn-sm" data-ng-show="model.credentials.network=='{{social.network_name}}'||!model.credentials.logged_in" data-ng-click="Login('{{social.network_name}}')"><i class="fa fa-{{social.network_name}}"></i> | {{model.action}} {{social.label}}</button>
</span>

1 Answer 1

0

no need to pass it with handlebars then... have you tried just social.network_name?

<button class="btn btn-{{social.network_name}} btn-sm" data-ng-show="model.credentials.network=='{{social.network_name}}'||!model.credentials.logged_in" data-ng-click="Login(social.network_name)"><i class="fa fa-{{social.network_name}}"></i> | {{model.action}} {{social.label}}</button>

When you pass the variable in a class, it needs to parsed for its value hence

class="btn brn-{{social.network_name}}"

if you are passing a variable to a function, no need for handlebars as it's already a scope variable and doesn't need string conversion.

ng-click='myFunction(social.network_name)'
1
  • Awesome - don't know why i had it in my head that i needed the handlebars! Commented Apr 30, 2014 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.