0

Hello i want pass angularjs variable to javascript function

<div class="col-sm-6 col-lg-2" ng-repeat="x in names | filter:FilterModeFirst">
    <div class="row">
        <div class="col-sm-16 col--lg-12">
            <div class="callout">
                <small class="text-muted">{{x.name}}</small>
                <br>
                <small class="h6">{{x.Indx}}%</small>
                <img src="./img/Add.png" style="cursor:pointer" ID="imgAdd" onclick="AddServiceName(" {{x.name}} ")"/>
            </div>
        </div>
    </div>
</div>
1
  • it's better to pass it into controller function (with ng-click="AddServiceName(x.name)"), which is initialised as $scope.AddServiceName = function(name){...} Commented Dec 19, 2017 at 10:17

2 Answers 2

1

use ng-click and remove the curly brackets.

ng-click="AddServiceName(x.name)"
Sign up to request clarification or add additional context in comments.

Comments

1

angularjs provide ng-click for listening click event.

In your case, you can change the code to this:

ng-click="AddServiceName(x.name)"

Comments

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.