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
0
votes
1 answer

AngualrJs - change value of href in link -

I can change properties in AngularJS by using a conditional If statement: OrgName: org && org.id==4162 ? 'Org1' : 'Org2' But i want to be able to change the href of a link depending on this value. How can I accomplish this? I have tried:
Paolo B
  • 3,026
  • 5
  • 21
  • 43
0
votes
1 answer

How to use pathlocationstrategy in angular 5 to set base href or APP_BASE_HREF?

Below is the code snippet: import { Router } from "@angular/router"; import { HttpClient } from "@angular/common/http"; import { environment } from "../../environments/environment"; import { …
hs27
  • 65
  • 8
0
votes
2 answers

downloading text file in postman but not in browser using restapi in angularjs

$scope.newFile is my response from backend. Actually my response should be a text file, which is working in postman.But in browser , I am getting Cannot GET …
Nicoleta Wilskon
  • 687
  • 1
  • 10
  • 32
0
votes
1 answer

ng-href doesn't work as expected

I have AngularJS v1.3.1 on the project. I have an anchor tag in my template:
Mikhail Batcer
  • 1,938
  • 7
  • 37
  • 57
0
votes
1 answer

How to pass parameter with ng-click in a ng-href?

Actually, I got a list of products and I would like to pass the current product id when click on the ng-href thanks to a function with ng-click in the ng-href. Here is my html file :
Cupkek05
  • 458
  • 1
  • 6
  • 22
0
votes
1 answer

Angular ng-href link not working in my dev server

In my application in local I am using {{abc}} In local it gets redirected to http://localhost:456/#/view/56 And in Dev link it should be redirected to https://www.dev.appname/projectname/#/view/56 but it gets redirected to…
Sri K
  • 1
  • 1
0
votes
3 answers

ng-href url not working

I don't know why ng-href isn't working. What i want to do is go from a modal to a view, passing the parameters {{user}} and {{email}} here's the state…
Rated Ace
  • 31
  • 7
0
votes
4 answers

Update href in AngularJS before navigating to the URL

In an AngularJS application I have the following code: Hello! Now, someMethod() and someProperty belong to the same service. Initially, someProperty.href has a…
Cosmin
  • 864
  • 3
  • 16
  • 34
0
votes
1 answer

Unable to change ng-href onClick event

I have a footer with a button in my angular app. The button has an ng-href attribute which should change during the ng-click event to affect the routing mechanism. For some reason I cant make this work. The ultimate goal is to append numbers, 1 to…
Alex
  • 1,982
  • 4
  • 37
  • 70
0
votes
2 answers

How to Open Large Data using ng-href or ng-click in new window in AngularJS

Can some one help me putting the DATA value new window . I want to make td cell with DATA name as hyperlink . If I click that DATA it should open new window to show the value . Demo JSON Data { "58231e66982cf7857fee2cb5": { "_id": { …
Mahesh G
  • 1,226
  • 4
  • 30
  • 57
0
votes
2 answers

Creating dynamic inside ngrepeat - every href value is the same

I am newer to angular/js. I'm using ng-repeat to repeat results (as list-items) from a webservice. I have to use some of the fields from the json results to create a dynamic URL to use on my webpage for each ng-repeat item. Everything repeats back…
0
votes
1 answer

Passing $location.search parameters using ng-href

Something really weird happens in my current code. So I'm using ng-repeat to create several elements based on an array of objects like this: My rendered HTML…
Sven Ya
  • 552
  • 1
  • 5
  • 12
0
votes
1 answer

AngularJS app occasionally refreshes with href & ng-href

Occasionally my AngularJS app refreshes when clicking a link that takes you somewhere within the site. There doesn't appear to be any consistency with this, sometimes it's with href="/foo" and other times with ng-href="/foo/{{bar}}" I seem to be…
LT86
  • 635
  • 2
  • 15
  • 29
0
votes
0 answers

Angularjs Delay of few seconds in mobile web

I have used this in my code , it works fine on web , but on mobile web when this anchor tag is clicked there is a pause for 3-4 sec then it is redirected Shirt how i can reduce this time in mobile web in angularjs
evilmind
  • 116
  • 1
  • 8