Skip to content

Commit 3d31999

Browse files
author
William Candillon
committed
Add ui-sref-active-includes attribute
fixes angular-ui#1252
1 parent 5e88789 commit 3d31999

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/stateDirectives.js

+22
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ function $StateRefDirective($state, $timeout) {
200200
* </li>
201201
* </ul>
202202
* </pre>
203+
*
204+
* @example
205+
* Given the following template where `app.users` is an abstract state and `app.users.default` its default child state:
206+
* <pre>
207+
* <ul>
208+
* <li ui-sref-active="active" ui-sref-active-includes="app.users" class="item">
209+
* <a href ui-sref="app.users.default">Users</a>
210+
* </li>
211+
* </ul>
212+
* </pre>
213+
*
214+
* When the app state is "app.users" (or any children states),
215+
* the resulting HTML will appear as (note the 'active' class):
216+
* <pre>
217+
* <ul>
218+
* <li ui-sref-active="active" ui-sref-active-includes="app.users" class="item active">
219+
* <a ui-sref="app.users.default" href="/users/default">Users</a>
220+
* </li>
221+
* </ul>
222+
* </pre>
203223
*/
204224

205225
/**
@@ -250,6 +270,8 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
250270
function isMatch() {
251271
if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
252272
return $state.$current.self === state && matchesParams();
273+
} else if(typeof $attrs.uiSrefActiveIncludes !== 'undefined') {
274+
return $state.includes($attrs.uiSrefActiveIncludes) && matchesParams();
253275
} else {
254276
return $state.includes(state.name) && matchesParams();
255277
}

0 commit comments

Comments
 (0)