角UI路由器UI的SREF活跃于父 [英] Angular ui router ui-sref-active on parent

查看:107
本文介绍了角UI路由器UI的SREF活跃于父的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的的状态,很多孩子的状态。如果我想在当我在孩子我必须这样做黑客的一个UI的SREF主动父的工作:

I have one parent state and many childs states. If I want the ui-sref-active on the parent to work when I am on one of the child I need to do this "hack":

$scope.isActive = function() {  
   return $state.includes('playLotteries.Index') 
       || $state.includes('playLotteries.Group')  
       || $state.includes('playLotteries.hunter');
   }

这是非常丑陋的方式,我有许多孩子因此它没有看起来很好的解决方案。任何人有此问题的另一个解决方案?

This is very ugly way and I have many children so its not seems like good solution. Anyone have another solution for this problem?

推荐答案

您可以检查父状态只不是检查的所有子状态

You can check parent state only instead of checking all child states

$scope.isActive = function() {  
   return $state.includes('playLotteries');
}

这篇关于角UI路由器UI的SREF活跃于父的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆