Search code examples
angularjsangular-ui-routerangular-filters

Using filters inside ui-sref


I have seen this answer, but it doesn't solve my problem, I want to generate the whole state name with my filter, not just use filter for my state parameters.

How can I have ui-sref to be generated from a filter like this?

  <a ui-sref="menuItem.key | srefFilter">                   
      <p>
         {{::menuItem.name}}
      </p>
  </a>

srefFilter is a filter that returns the state name based on value passed to it.


Solution

  • Use {{ }} (Angular expressions)

    LIVE DEMO

    <a ui-sref="{{someValue | srefFilter}}">This link has ui-sref with a filter</a>