Search code examples
htmlvariablesangularjs-directivehttp-status-code-404angular-ng-if

Angular js 404 error with angular template variables even when using ng-if on page load?


Why is this

INFO     2018-02-16 21:32:33,192 module.py:788] default: "GET /%5B%7Binstance.file_url%7D%5D HTTP/1.1" 404 233

showing up in my terminal given that instance.file_url is used in

<a class="source" href="[{instance.file_url}]" title="[{instance.file_url}]" target="_blank">source</a>

(Note: [{}] is not an error: {{}} conflicts with jinja2 so I changed angular's)

and contained with in a <section ng-if="instance"> tag??

How do I fix this? Or is it normal? Any debugging tips?

I have no idea why it's querying for values I'm not asking for


Solution

  • Maybe try changing the href to ng-href? Then the anchor tag won't have a href attribute until AngularJS interpolates the value, which shouldn't happen until that ng-if resolves to truthy.

    Here's the ngHref documentation for reference: https://docs.angularjs.org/api/ng/directive/ngHref