1

I have a ng-repeat and I want to call a function in a ng-mouseover using two parameter as follow:

ng-mouseover="textlimit({{item.id}}, 900)"

If I do that the variable appears correctly in the sources, but the console outputs an angular syntax error. My function isn't working since then I added this variable.

How should I proceed?

PS: the variable is a number: 1, 2, 3, 4 etc.

Thanks

2
  • You just have to pass it as ng-mouseover="textlimit(item.id, 900)" Remove interpolation. Commented Aug 28, 2014 at 14:04
  • @SKYnine take a look at my answer Commented Aug 28, 2014 at 14:11

1 Answer 1

4

No need of {{}} in ng-mouseover since its an angular component,

you can use the method directly like

ng-mouseover="textlimit(item.id, 900)"

instead of

ng-mouseover="textlimit({{item.id}}, 900)"

A sample example is shown below

Working Demo

html

<div ng-app='myApp' ng-controller="ArrayController">
   <a href="#" onclick="return false;" ng-mouseover="textlimit(item.id, 900)">Download</a>
</div>

script

var app = angular.module('myApp', []);
app.controller('ArrayController', function ($scope) {
    $scope.item = {
        id:21
    }
    $scope.textlimit = function(id, value)
    {
        console.log('id::',id);
        console.log('value::',value);
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

... Thanks! couldn't find anything about it.

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.