tutorialpro.org

">

tutorialpro.org

" />
Easy Tutorial
❮ Home Ng Ng List ❯

AngularJS ng-href Directive

AngularJS Reference Manual


AngularJS Example

Using AngularJS to set up a link:

<div ng-init="myVar = 'http://www.tutorialpro.org'">
   <h1>tutorialpro.org</h1>
   <p>Visit <a ng-href="{{myVar}}">{{myVar}}</a> to learn!</p>
</div>

Definition and Usage

The ng-href directive overrides the native <a> element's href attribute.

If there is AngularJS code in the value of href, you should use ng-href instead of href.

The ng-href directive ensures the link is normal, even if the link is clicked before AngularJS executes the code.


Syntax

The <a> element supports this directive.


Parameter Values

Value Description
expression String, the result of the expression execution

AngularJS Reference Manual

❮ Home Ng Ng List ❯