Reputation: 189
I have a problem. The value of the expression {{}}
is not inserted in ng-click.
My code:
<div ng-repeat="dir in model.Directories">
<a ng-href="" id="{{dir.Name}}" ng-click='clickToPath("http://localhost:9298/api/browse?path={{dir.Path}}")'>{{dir.Name}}</a>
</div>
Value of {{dir.Name}}
is inserted succesfully. But value of {{dir.Path}}
in ng-click is not inserted, but only inserted {{dir.Path}}
as is.
Help me!
Thanks a lot!
Upvotes: 1
Views: 64
Reputation: 2561
To provide an answer because everyone is just commenting.
The answer is what @John Smith said:
ng-click='clickToPath("http://localhost:9298/api/browse?path=" + dir.Path)'
You do not need to use {{}} because ngClick is an angular directive itself.
@Neozaru To complete John Smith answer : {{exp}} tells Angular to take "exp" as an expression (instead of reading "exp" litteraly). Since "ngClick" is an attribute exposed by AngularJS, the framework will consider what is inside directly as an expression, so you won't need the {{}} (and finally can't use them). Same thing for most AngularJS directives (ng-if, ng-show, ng-repeat, ...)
Upvotes: 4