angularjsangularjs-ng-href

AngularJS ngHref inside ngRepeat doesn't evaluate value


I have the following markup:

<ul ng-if="item.children.length && item.open" class="fadeIn">
    <li ng-repeat="child in item.children" ng-show="child.visible">
        <a ng-href="#/{{ child.link }}">
            <span ng-bind-html="child.title"></span>
        </a>
    </li>
</ul>

The result, when the controller runs is a LI element containing a link, which contains a span, for each item in the list, which is the expected result.

The problem is that when clicking the link, nothing happens since the link is empty (#/). It is as if {{ child.link }} is not evaluated.

If i hardcode my preferred link (#/whatever), the routeProvider picks it up and it works.

I have even changed the name of the link parameter, to no avail. The scope menu structure contains a 'link' parameter for each menu.

There are no error in the console

Why isn't {{child.link}} evaluated?


Solution

  • This is the 2nd time i have been had like this. This code is within a django template, and i have forgotten to use a verbatim tag. That means that Django will evaluate the expression to nothing before angular can have a chance to process this.

    Thanks for all your help, D.