# `ngHref` (directive in module `ng` )

Improve this doc

## Description

Using Angular markup like {{hash}} in an href attribute makes the page open to a wrong URL, if the user clicks that link before angular has a chance to replace the {{hash}} with actual URL, the link will be broken and will most likely return a 404 error. The `ngHref` directive solves this problem.

The buggy way to write it:

    <a href="http://www.gravatar.com/avatar/{{hash}}"/>

The correct way to write it:

    <a ng-href="http://www.gravatar.com/avatar/{{hash}}"/>

## Usage

as attribute

    <A ng-href="{template}">
       ...
    </A>

### Parameters

- `ngHref – {template} –`

  any string which can contain `{{}}` markup.

## Example

This example uses `link` variable inside `href` attribute:

#### Source

#### Demo