vlio20
vlio20

Reputation: 9295

Calling controller function from element attribute

how can I call a controller function from html attribute. For example:

Controller function:

$scope.foo = function(id)
{
    return id+1;
}

And here is the html:

<div ng-repeat obj in arr id="foo(obj.id)"></div>

This way I am getting ...id=foo(obj.id) instead of ...id="2" (if obj.id is equal 1).

Thanks!

Upvotes: 0

Views: 46

Answers (1)

user3739239
user3739239

Reputation: 146

to call angular rendering you need to had {{ }}. Try this: id="{{foo(obj.id)}}"

Upvotes: 1

Related Questions