2

I am using angularjs and the ui-router. How can I fire a click-event in this jscode:

<a ng-if="item.external!==true" id="nav-drafts"
   class="standard-menu-item comm-icon-news" draggable="false"
   ui-sref="root.drafts.index" ui-sref-opts="{inherit: false}"
   href="#/drafts">
    <span class="icon sso-file"></span>
    <span class="menu-item-label" ng-bind-html="item.label">Edits</span>
</a>

How can I insert a click event inside the anchore passing in the ui-sref property?

1 Answer 1

2

You could consider redirecting manually on click(ng-click) event handler

HTML

<a ng-if="item.external!==true" id="nav-drafts" 
   class="standard-menu-item comm-icon-news" draggable="false" 
   ng-click="navigate('root.drafts.index', {inherit: false})">
    <span class="icon sso-file"></span>
    <span class="menu-item-label" ng-bind-html="item.label">Edits</span>
</a>

Controller

navigate(stateName, params) {
   //do other stuff before redirecting
   $state.go(stateName, params); //call this for navigating to other state.
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.