From 90d3cfa39e6b69ad3b73c615b5a63b3eee481165 Mon Sep 17 00:00:00 2001 From: Tim Kindberg Date: Thu, 24 Apr 2014 23:29:15 -0400 Subject: [PATCH] chore(docs): add relative naming docs for 'is', 'includes' and 'get'. fixes #637 --- src/state.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/state.js b/src/state.js index 5bac8bfb8..0ab449ec7 100644 --- a/src/state.js +++ b/src/state.js @@ -974,13 +974,18 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * * @example *
+     * $state.$current.name = 'contacts.details.item';
+     *
+     * // absolute name
      * $state.is('contact.details.item'); // returns true
      * $state.is(contactDetailItemStateObject); // returns true
      *
-     * // everything else would return false
+     * // relative name (. and ^), typically from a template
+     * // E.g. from the 'contacts.details' template
+     * 
Item
*
* - * @param {string|object} stateName The state name or state object you'd like to check. + * @param {string|object} stateName The state name (absolute or relative) or state object you'd like to check. * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like * to test against the current active state. * @returns {boolean} Returns true if it is the state. @@ -1013,11 +1018,17 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { *
      * $state.$current.name = 'contacts.details.item';
      *
+     * // Using partial names
      * $state.includes("contacts"); // returns true
      * $state.includes("contacts.details"); // returns true
      * $state.includes("contacts.details.item"); // returns true
      * $state.includes("contacts.list"); // returns false
      * $state.includes("about"); // returns false
+     *
+     * // Using relative names (. and ^), typically from a template
+     * // E.g. from the 'contacts.details' template
+     * 
Item
+ * *
* * @description @@ -1036,7 +1047,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * $state.includes("item.**"); // returns false * * - * @param {string} stateOrName A partial name to be searched for within the current state name. + * @param {string} stateOrName A partial name, relative name, or glob pattern + * to be searched for within the current state name. * @param {object} params A param object, e.g. `{sectionId: section.id}`, * that you'd like to test against the current active state. * @returns {boolean} Returns true if it does include the state @@ -1118,7 +1130,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * @description * Returns the state configuration object for any specific state or all states. * - * @param {string|object=} stateOrName If provided, will only get the config for + * @param {string|object=} stateOrName (absolute or relative) If provided, will only get the config for * the requested state. If not provided, returns an array of ALL state configs. * @returns {object|array} State configuration object or array of all objects. */