1

I'm trying to use an angular variable as a JavaScript parameters like this:

 <li ng-repeat="link in Links">
    <button data-icon="gear" data-role="button" data-iconpos="right" type="button" id="bitrate_btn_{{ link.Code }}" class="bitrate_btn btn" onClick="play_live_ind({{link.Code}});">
        {{ link.Title }} ( {{ link.Bitrate }} Kbps )
    </button>
 </li>

As you can see I'm calling a method called play_live_ind like this:

play_live_ind({{link.Code}});

It's not working, as the page loads it exactly prints play_live_ind({{link.Code}});

How can I pass the value of link to this JavaScript function?

This is a jw-player function that I can't rewrite it in angular because it has many function call on itself. So I need to call this function in javascript

So I just need a solution to pass the angular variable value to the Javascript function

5
  • 3
    Use ng-click instead of onClick. Commented Jan 27, 2015 at 9:53
  • This function is a javascript function, I used it with ng-click but because it's not a angular fucntion, it won't run, how can I run it then? Commented Jan 27, 2015 at 11:04
  • define play_live_ind as $scope.play_live_ind = function(inputs) { // function body} Commented Jan 27, 2015 at 11:07
  • This is not my function, this is jw-player functions so I can't rewrite them in angular, it has many dependencies, so I need a solution to pass the angular value to the javascript function Commented Jan 27, 2015 at 18:50
  • And also, onClick should be changed to - onclick Commented Jan 28, 2015 at 4:14

1 Answer 1

2

Use ng-click instead of onClick, and define play_live_ind in your $scope.

//html
ng-click="play_live_ind(link.Code)";

//js
$scope.play_live_ind = function(inputs) { 
                          // function body 
                       }
Sign up to request clarification or add additional context in comments.

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.