byCoder
byCoder

Reputation: 9184

AngularJS ui-router: ui-sref and directive

I have such html:

<span ui-sref="{{detailsArt(art.Id)}}" check-val></span>

and in my directive check-val i have:

link: function(scp, el, attr) {
  el.bind('click', function(event) {
    //some logic with if:
    event.preventDefault();
  });
}

and it's not working with ui-sref(

when i'm using $state.go('detailsArt', {artId: art.Id}) this directive is working fine.

Is it possible to use ui-sref with directive click handler, and how?

Upvotes: 1

Views: 310

Answers (1)

michelem
michelem

Reputation: 14590

Because it should be: ui-sref="detailsArt({artId : art.Id})" And of course you need an anchor tag a as said by Pankaj

<a ui-sref="detailsArt({artId: art.Id})" check-val></a>

Upvotes: 1

Related Questions