Search code examples
javascriptangularjsangularjs-ng-repeatangularjs-ng-href

Angularjs ng-href Bug?


I came across something strange and wanted to see if anyone had the same problem. I am using Angularjs with the ng-href directive within an ng-repeat as below. The issue I encountered is that if the ng-href tag just contains the {{var}}, it will do nothing.

<li ng-repeat="app in apps">   
<a ng-href="{{app.name}}">{{app.name}}</a> <--THIS DOES NOT WORK
</li>

If I add a space (or anything else) before or after the {{var}} as illustrated below it links as expected.

<li ng-repeat="app in apps">
<!-- NOTE THE BUG? HERE ... without a leading or trailing character, this doesn't work!! -->   
<a ng-href=" {{app.name}}">{{app.name}}</a> <--THIS WORKS (added a leading space)
</li>

Am I missing something here? Is this expected functionality? A bug? I tested in Chrome and Firefox with the same result...


Solution

  • There seem to be a ticket about this bug. The ticket contains some workarounds and fixes.