Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if current state in ui-router is a child of an abstract state

I have an abstract state "settings" with a set of children defined using strings, like "settings.personal", "settings.business" and so on. I need to check in a higher level shared controller if current state is a child of abstract "settings" state.

I can't figure out how to check for this? I tried to use $state.is hoping it's smart enough to detect this but it seems it's not.

$state.is("settings") # => false
$state.is("settings.personal") # => true

So, any other idea?

like image 579
Senthe Avatar asked May 19 '16 13:05

Senthe


1 Answers

Ok I now see that there's also $state.includes method which does exactly what I wanted.

I'll leave this question for community to judge if it's worth keeping or should it be deleted.

like image 109
Senthe Avatar answered Nov 15 '22 21:11

Senthe