How to use ng-href with absolute url?

前端 未结 3 1971
孤独总比滥情好
孤独总比滥情好 2021-02-12 23:04

I\'m still new to angularjs, and I have a problem that I seem to not be able to find solution, and I don\'t have time to go look into angular source.

This is my scenario

3条回答
  •  无人共我
    2021-02-12 23:25

    I solved it by prefixing data in json with 'http://' to make them trully absolute urls, and angularjs respects that.

    Then I understood that angular is actually not doing anything with value, it is just putting it there as it is, and it is my fault to see that.

    updating code to this solves problem when all urls are like 'www.google.com'

    {{link.title}}
    

    Plain old 'inspect element' uncovered issue, and I ignored the fact that ng-href binds from {{value}} syntax, so this is why my first attempt to put ng-href="'http://'+{{value}}" failed and led me to ask question prematurely, but I'm not sure if I should delete it as I may not be only one making such mistake.

提交回复
热议问题