简体   繁体   English

AngularJS ui-router: ui-sref 和指令

[英]AngularJS ui-router: ui-sref and directive

I have such html:我有这样的html:

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

and in my directive check-val i have:在我的指令 check-val 中,我有:

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

and it's not working with ui-sref(它不适用于 ui-sref(

when i'm using $state.go('detailsArt', {artId: art.Id}) this directive is working fine.当我使用$state.go('detailsArt', {artId: art.Id})这个指令工作正常。

Is it possible to use ui-sref with directive click handler, and how?是否可以将 ui-sref 与指令单击处理程序一起使用,以及如何使用?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS:ui-router href重写为ui-sref - AngularJS: ui-router href rewrite into ui-sref 如何在ui-router AngularJS中使用ui-sref - How to use ui-sref in ui-router AngularJS 在指令的模板中,如何让角度ui-router的ui-sref工作? - How to get angular ui-router's ui-sref to work, when inside a directive's template? 如何使用AngularJS ui路由器构建与URL相同的URL <ui-sref> 在控制器而不是HTML中? - How to use AngularJS ui-router to build same URL as <ui-sref> in controller instead of HTML? AngularJS ui路由器ui-sref导致“未捕获的TypeError:无法读取未定义的属性&#39;0&#39;”错误 - AngularJS ui-router ui-sref causing “Uncaught TypeError: Cannot read property '0' of undefined” error AngularJs ui-router ui-sref不使用参数从嵌套状态生成href - AngularJs ui-router ui-sref not generating href from nested state with parameter 使用ui-sref解决ui-router状态下的对象 - Resolving object in state of ui-router with ui-sref ui-router中ui-sref属性的动态更改 - Dynamic changing of ui-sref attribute in ui-router AngularJS UI路由器-&gt;使用ui-sref时无法解析 - AngularJS UI Router -> Could not resolve when using ui-sref AngularJS UI路由器:ui-sref是否不更新地址栏中的URL? - AngularJS UI Router: ui-sref not updating URL in address bar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM