AngularJS ng-href
Directive
Example
Make a href using AngularJS:
<div ng-init="myVar = 'https//www.noidatut.com'">
<h1>Tutorials</h1>
<p>Go to <a ng-href="{{myVar}}">{{myVar}}</a>
to learn!</p>
</div>
Try it yourself »
Definition and Usage
The ng-href
directive overrides the original href attribute of
an <a> element.
The ng-href
directive should be used instead of href
if you have AngularJS code inside the href value.
The ng-href
directive makes sure the link is not broken even if
the user clicks the link before AngularJS has evaluated the code.
Syntax
<a ng-href="string"></a>
Supported by the <a> element.
Parameter Values
Value | Description |
---|---|
string | A string value, or an expression resulting in a string. |