Skip to content

Commit 90d3cfa

Browse files
committed
chore(docs): add relative naming docs for 'is', 'includes' and 'get'.
fixes #637
1 parent da59af3 commit 90d3cfa

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/state.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,13 +974,18 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
974974
*
975975
* @example
976976
* <pre>
977+
* $state.$current.name = 'contacts.details.item';
978+
*
979+
* // absolute name
977980
* $state.is('contact.details.item'); // returns true
978981
* $state.is(contactDetailItemStateObject); // returns true
979982
*
980-
* // everything else would return false
983+
* // relative name (. and ^), typically from a template
984+
* // E.g. from the 'contacts.details' template
985+
* <div ng-class="{highlighted: $state.is('.item')}">Item</div>
981986
* </pre>
982987
*
983-
* @param {string|object} stateName The state name or state object you'd like to check.
988+
* @param {string|object} stateName The state name (absolute or relative) or state object you'd like to check.
984989
* @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like
985990
* to test against the current active state.
986991
* @returns {boolean} Returns true if it is the state.
@@ -1013,11 +1018,17 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
10131018
* <pre>
10141019
* $state.$current.name = 'contacts.details.item';
10151020
*
1021+
* // Using partial names
10161022
* $state.includes("contacts"); // returns true
10171023
* $state.includes("contacts.details"); // returns true
10181024
* $state.includes("contacts.details.item"); // returns true
10191025
* $state.includes("contacts.list"); // returns false
10201026
* $state.includes("about"); // returns false
1027+
*
1028+
* // Using relative names (. and ^), typically from a template
1029+
* // E.g. from the 'contacts.details' template
1030+
* <div ng-class="{highlighted: $state.includes('.item')}">Item</div>
1031+
*
10211032
* </pre>
10221033
*
10231034
* @description
@@ -1036,7 +1047,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
10361047
* $state.includes("item.**"); // returns false
10371048
* </pre>
10381049
*
1039-
* @param {string} stateOrName A partial name to be searched for within the current state name.
1050+
* @param {string} stateOrName A partial name, relative name, or glob pattern
1051+
* to be searched for within the current state name.
10401052
* @param {object} params A param object, e.g. `{sectionId: section.id}`,
10411053
* that you'd like to test against the current active state.
10421054
* @returns {boolean} Returns true if it does include the state
@@ -1118,7 +1130,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
11181130
* @description
11191131
* Returns the state configuration object for any specific state or all states.
11201132
*
1121-
* @param {string|object=} stateOrName If provided, will only get the config for
1133+
* @param {string|object=} stateOrName (absolute or relative) If provided, will only get the config for
11221134
* the requested state. If not provided, returns an array of ALL state configs.
11231135
* @returns {object|array} State configuration object or array of all objects.
11241136
*/

0 commit comments

Comments
 (0)