ng-href
Directiva AngularJS
Ejemplo
Haz un href usando AngularJS:
<div ng-init="myVar = 'https://www.w3schools.com'">
<h1>Tutorials</h1>
<p>Go to <a ng-href="{{myVar}}">{{myVar}}</a>
to learn!</p>
</div>
Definición y uso
La ng-href
directiva anula el atributo href original de un elemento <a>.
La ng-href
directiva debe usarse en lugar de href
si tiene código AngularJS dentro del valor href.
La ng-href
directiva se asegura de que el enlace no se rompa incluso si el usuario hace clic en el enlace antes de que AngularJS haya evaluado el código.
Sintaxis
<a ng-href="string"></a>
Compatible con el elemento <a>.
Valores paramétricos
Value | Description |
---|---|
string | A string value, or an expression resulting in a string. |