Michel
Michel

Reputation: 23615

Why is there a ng-src and not a ng-href?

I have a question about Angular (the code comes from the Angular tutorial)

It's about this code: <a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}"></a>

The tutorial says:

[...]using an image tag with the ngSrc directive. That directive prevents the browser from treating the Angular {{ expression }} markup literally

However, in the same line of code, there is this part: <a href="#/phones/{{phone.id}}"

in which the same construct is used, namely the value of a property in a string.

Imho the href="" and the src="" are both properties of a html tag, but for img there is a separate directive (ng-src) but for the A tag there is no ng-href directive?

PS I'm a .Net dev, newbee to Angular

Upvotes: 0

Views: 711

Answers (1)

lex82
lex82

Reputation: 11317

There is ng-href for links. It is the ng-src for links you are looking for.

Upvotes: 1

Related Questions