Skip to content

Add ui-sref-active-includes attribute #1254

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/stateDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@ function $StateRefDirective($state, $timeout) {
* </li>
* </ul>
* </pre>
*
* @example
* Given the following template where `app.users` is an abstract state and `app.users.default` its default child state:
* <pre>
* <ul>
* <li ui-sref-active="active" ui-sref-active-includes="app.users" class="item">
* <a href ui-sref="app.users.default">Users</a>
* </li>
* </ul>
* </pre>
*
* When the app state is "app.users" (or any children states),
* the resulting HTML will appear as (note the 'active' class):
* <pre>
* <ul>
* <li ui-sref-active="active" ui-sref-active-includes="app.users" class="item active">
* <a ui-sref="app.users.default" href="/users/default">Users</a>
* </li>
* </ul>
* </pre>
*/

/**
Expand Down Expand Up @@ -250,6 +270,8 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
function isMatch() {
if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
return $state.$current.self === state && matchesParams();
} else if(typeof $attrs.uiSrefActiveIncludes !== 'undefined') {
return $state.includes($attrs.uiSrefActiveIncludes) && matchesParams();
} else {
return $state.includes(state.name) && matchesParams();
}
Expand Down