简体   繁体   中英

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?

因为它应该是: ui-sref="detailsArt({artId : art.Id})"当然你需要一个锚标签a正如 Pankaj 所说

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM