ui-sref (directive in module ui.router.state )

Description

A directive that binds a link (<a> tag) to a state. If the state has an associated URL, the directive will automatically generate & update the href attribute via the $state.href() method. Clicking the link will trigger a state transition with optional parameters.

Also middle-clicking, right-clicking, and ctrl-clicking on the link will be handled natively by the browser.

You can also use relative state paths within ui-sref, just like the relative paths passed to $state.go(). You just need to be aware that the path is relative to the state that the link lives in, in other words the state that loaded the template containing the link.

Dependencies

Usage

as attribute
<ANY ui-sref="{string}">
   ...
</ANY>

Parameters

Example

<a ui-sref="home">Home</a> | <a ui-sref="about">About</a>

<ul>
  <li ng-repeat="contact in contacts">
    <a ui-sref="contacts.detail({ id: contact.id })">{{ contact.name }}</a>
  </li>
</ul>