-
Notifications
You must be signed in to change notification settings - Fork 3k
Wildcard support in $state.is() and $state.includes() #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried |
I need to select all 2nd hierarchical states but not the 3rd. I don't think there is any way to achieve this using In the case that the wildcard character become supported, the desired states can be selected either through:
or
I've updated the title of the issue accordingly. |
Just some pseudo code (you'd have to really figure it out) but what about testing if $state.parent is equal to "choose" |
@gsklee I'd suggest you put add a property like |
@ksperling That seems to be a very valuable info about the current structure of the state and I wonder why not include that info officially? |
hm well the level seems like something that would change fairly easily if you decide to insert another state at the top of your hierarchy... A bit like counting how many directories deep you are in a file system, if you move around a part of the tree the depth of everything in that tree will likely change. So I think as a generic mechanism it's probably a little too brittle. |
I don't think we're going to approach this in this way. Once we implement an API for traversing and manipulating the state tree, we can think about implementing accessors like |
I would try to do it using regexp $state.mathes = function(stateName) {
var regexp = new RegExp('^'+stateName.replace(".", "\.").replace('*', '[\w]+'))
return regexp.test($state.current.name);
} And you may use wildcards to find any you needed state |
I am doing some app that given the following state hierarchy:
I need to apply some CSS classes when the state is in the second hierarchy but not the third.
Currently the only way to do so seems to be hard-coding every possible state:
It would be nice if we can simply do something like
$state.is('choose.*')
.The text was updated successfully, but these errors were encountered: