Questions tagged [angularjs-ng-href]

Part of AngularJS. Using Angular markup like {{hash}} in an href attribute will make the link go to the wrong URL if the user clicks it before Angular has a chance to replace the {{hash}} markup with its value. Until Angular replaces the markup the link will be broken and will most likely return a 404 error. The ngHref directive solves this problem.

The wrong way to write it:

<a href="http://www.gravatar.com/avatar/{{hash}}">link1</a>

The correct way to write it:

<a ng-href="http://www.gravatar.com/avatar/{{hash}}">link1</a>

Usage

<A
  ng-href="template">
...
</A>

Reference - AngularJS ngHref docs

55 questions
25
votes
2 answers

Angularjs function in ng-href

I want to call a function in ng-href and return the link from the function. When I click the function it sends page to that function in url. Like: localhost/pageLink() Link How can i run the function and return correct…
17
votes
3 answers

How to use ng-href with absolute url?

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: I have some json data with collection of urls that I want to show on screen. I…
Goran Obradovic
  • 8,951
  • 9
  • 50
  • 79
10
votes
4 answers

AngularJS ng-href does not go to link

I've checked the docs and the ng-href not working thread on here already but I'm stumped. Does ng-href require a full path? Mine currently looks like go…
code-sushi
  • 719
  • 3
  • 7
  • 23
8
votes
4 answers

Looking for substring alternative javascript

Basically my problem is I am using the substring method on the variable version for the result then to be used inside a URL using ng-href: substring(0, 3) version 9.1.0 = 9.1 (good) version 9.2.0 = 9.2 (good) version 9.3.0 = 9.3 (good) .. version…
Jam12345
  • 133
  • 1
  • 1
  • 7
4
votes
1 answer

Using ng-href with geo: Uri in Cordova does not work

I am trying to use the geo: uri in Cordova. It works when I do something like: link1 but if I do something like with angular: {{location}}>link2 and location =…
4
votes
2 answers

Can I have Angular ng-href bind variables within a string

I'd like to bind a links href property to a variable in my controller but I'd also like to have that url be bound to variables. I'd like to accomplish this using the built in binding and without having to manually watch for changes and reload the…
Stephen Marsh
  • 95
  • 1
  • 1
  • 7
3
votes
1 answer

AngularJS using an expression as an href

My webpage is set up so when a user selects one of many options a number of hyperlinks will appear and take you to that webpage. To make my code less DRY I created an ng-repeat div to output all the options for the user. All the hyperlinks appear on…
Markus
  • 297
  • 4
  • 19
3
votes
2 answers

Set ng-href to current page

Is it possible to set ng-href to go to the current page? eg: facebook When the above runs, I keep getting:
John Fu
  • 1,812
  • 2
  • 15
  • 20
2
votes
4 answers

Display string containing HTML tag in Angular

I checked for answers in SO but couldn't find satisfying answer. So here I'm asking : I have a string as follow var string = "With this you have agreed with the rules and condition" Which I need to render as both string (for the…
Fred A
  • 1,602
  • 1
  • 24
  • 41
2
votes
1 answer

Why ng-href behaving weird while parsing geo string

I've multiple geo string like geo:0,0q=1+a+bc, and I'm gonna assign this to ng-href of the anchor tag. Like below I'm doing it. HTML Location
Above tag is rendering fine on HTML but adding unsafe: string…
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
1
vote
0 answers

no href in anchor tag selenium python

Python Version 3.9.12, Selenium Version 4.8.0 Hi, I am trying to scrape this link Using Selenium Python When you go to this link and press the Search Times button, you will see list of available restaurant. #Search Button Click search_times =…
1
vote
2 answers

How to pass a parameter in AngularJS

I have a list of products in Angular JS and when I click the link for a certain item I want to sent the index of that product to a new page where to get all the details for that item (category, price etc) base on the item index. The informations…
1
vote
4 answers

URL link not redirecting properly in Angularjs

I have a link in my announce.obj. But when I clicked it, it's giving me the wrong url (http://www./) in the browser. html

{{data.links}}

data.links value www.google.com Should I add an…
code.cycling
  • 1,246
  • 2
  • 15
  • 33
1
2 3 4