Skip to content

Commit 612d2e1

Browse files
docs(inherit): Update docs for inherit params to be more consistent.
Closes angular-ui/ui-router#3342
1 parent bc1f554 commit 612d2e1

File tree

5 files changed

+51
-31
lines changed

5 files changed

+51
-31
lines changed

src/params/interface.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,11 @@ export interface ParamDeclaration {
316316
raw: boolean;
317317

318318
/**
319-
* Enables/disables inheriting of this parameter value
319+
* Enables/disables inheriting of this parameter's value
320320
*
321-
* When a transition is run with [[TransitionOptions.inherit]] set to `true`, the current param values are inherited.
322-
* Parameters values which have `inherit: false` will not be inherited.
321+
* When a transition is run with [[TransitionOptions.inherit]] set to
322+
* `true`, the current param values are inherited in the new transition.
323+
* However, parameters values which have `inherit: false` set will *not be inherited*.
323324
*
324325
* #### Example state :
325326
* ```js
@@ -344,6 +345,10 @@ export interface ParamDeclaration {
344345
*
345346
* ---
346347
*
348+
* See also [[TransitionOptions.inherit]] and [[ParamTypeDefinition.inherit]]
349+
*
350+
* ---
351+
*
347352
* Default: `true`
348353
*/
349354
inherit: boolean;
@@ -577,8 +582,9 @@ export interface ParamTypeDefinition {
577582
/**
578583
* Enables/disables inheriting of parameter values (of this type)
579584
*
580-
* When a transition is run with [[TransitionOptions.inherit]] set to `true`, the current param values are inherited.
581-
* Param values whose type has `inherit: false` will not be inherited.
585+
* When a transition is run with [[TransitionOptions.inherit]] set to
586+
* `true`, the current param values are inherited in the new transition.
587+
* However, parameters whose type has `inherit: false` set will *not be inherited*.
582588
*
583589
* The internal parameter type of `hash` has `inherit: false`.
584590
* This is used to disable inheriting of the hash value (`#`) on subsequent transitions.
@@ -592,6 +598,11 @@ export interface ParamTypeDefinition {
592598
* // The url's hash will be cleared.
593599
* $state.go('home.nest');
594600
* ```
601+
*
602+
* ---
603+
*
604+
* See also [[TransitionOptions.inherit]] and [[ParamDeclaration.inherit]]
605+
*
595606
*/
596607
inherit?: boolean;
597608

src/state/interface.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,32 @@ export interface LazyLoadResult {
701701
states?: StateDeclaration[];
702702
}
703703

704-
/** @internalapi */
704+
/**
705+
* An options object for [[StateService.href]]
706+
*/
705707
export interface HrefOptions {
708+
/**
709+
* Defines what state to be "relative from"
710+
*
711+
* When a relative path is found (e.g `^` or `.bar`), defines which state to be relative from.
712+
*/
706713
relative?: StateOrName;
714+
715+
/**
716+
* If true, and if there is no url associated with the state provided in the
717+
* first parameter, then the constructed href url will be built from the first
718+
* ancestor which has a url.
719+
*/
707720
lossy?: boolean;
721+
722+
/**
723+
* If `true` will inherit parameters from the current parameter values.
724+
*/
708725
inherit?: boolean;
726+
727+
/**
728+
* If true will generate an absolute url, e.g. `http://www.example.com/fullurl`.
729+
*/
709730
absolute?: boolean;
710731
}
711732

src/state/stateObject.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ export class StateObject {
172172
}
173173

174174
/**
175-
* Gets the state's `Param`eters
175+
* Gets the state's `Param` objects
176176
*
177-
* Gets [[Param]] information that is owned by the state.
178-
* If `opts.inherit` is true, it also includes the ancestor states' [[Param]] information.
177+
* Gets the list of [[Param]] objects owned by the state.
178+
* If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects.
179179
* If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object
180180
*
181181
* @param opts options
@@ -190,7 +190,7 @@ export class StateObject {
190190
/**
191191
* Returns a single [[Param]] that is owned by the state
192192
*
193-
* If `opts.inherit` is true, it also searches the ancestor states` [[Param]] information.
193+
* If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.
194194
* @param id the name of the [[Param]] to return
195195
* @param opts options
196196
*/

src/state/stateService.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ export class StateService {
213213
};
214214

215215
/**
216-
* Transition to a different state or parameters
216+
* Transition to a different state and/or parameters
217217
*
218218
* Convenience method for transitioning to a new state.
219219
*
220220
* `$state.go` calls `$state.transitionTo` internally but automatically sets options to
221-
* `{ location: true, inherit: true, relative: $state.$current, notify: true }`.
222-
* This allows you to easily use an absolute or relative to path and specify
223-
* only the parameters you'd like to update (while letting unspecified parameters
224-
* inherit from the currently active ancestor states).
221+
* `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
222+
* This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
223+
* It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
224+
* inherit from the current parameter values (because of `inherit: true`).
225225
*
226226
* #### Example:
227227
* ```js
@@ -244,12 +244,8 @@ export class StateService {
244244
*
245245
* @param params A map of the parameters that will be sent to the state, will populate $stateParams.
246246
*
247-
* Any parameters that are not specified will be inherited from currently defined parameters (because of `inherit: true`).
248-
* This allows, for example, going to a sibling state that shares parameters specified in a parent state.
249-
*
250-
* Parameter inheritance only works between common ancestor states, I.e.
251-
* transitioning to a sibling will get you the parameters for all parents, transitioning to a child
252-
* will get you all current parameters, etc.
247+
* Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
248+
* This allows, for example, going to a sibling state that shares parameters defined by a parent state.
253249
*
254250
* @param options Transition options
255251
*
@@ -496,14 +492,6 @@ export class StateService {
496492
* @param params An object of parameter values to fill the state's required parameters.
497493
* @param options Options object. The options are:
498494
*
499-
* - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the
500-
* first parameter, then the constructed href url will be built from the first navigable ancestor (aka
501-
* ancestor with a valid url).
502-
* - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
503-
* - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
504-
* defines which state to be relative from.
505-
* - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
506-
*
507495
* @returns {string} compiled state url
508496
*/
509497
href(stateOrName: StateOrName, params: RawParams, options?: HrefOptions): string {

src/transition/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export interface TransitionOptions {
3737

3838
/**
3939
* This option sets whether or not the transition's parameter values should be inherited from
40-
* the current state parameters.
40+
* the current parameter values.
4141
*
42-
* - If `true`, it will inherit parameters from current state.
42+
* - If `true`, it will inherit parameter values from the current parameter values.
4343
* - If `false`, only the parameters which are provided to `transitionTo` will be used.
4444
*
4545
* @default `false`

0 commit comments

Comments
 (0)