# Class StateObject

Internal representation of a ng-router state.

Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].

A registered [[StateDeclaration]] is augmented with a getter ([[StateDeclaration.$$state]]) which returns the corresponding [[StateObject]] object.

This class prototypally inherits from the corresponding [[StateDeclaration]]. Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].

#### Implements

- Defined in src/router/state/state-object.js:19
- Defined in src/router/state/state-object.js:116
- Defined in src/router/state/state-object.js:118

##### Index

### Constructors

constructor

### Properties

__stateObjectCache
$$state
includes
name
navigable
params
parent
self
url

### Methods

fqn
is
parameter
parameters
root
toString
isState
isStateDeclaration

## Constructors

### constructor

- new StateObject(config: StateDeclaration): StateObject

  #### Parameters

  - config: StateDeclaration

  #### Returns StateObject

  - Defined in src/router/state/state-object.js:31

## Properties

### __stateObjectCache

__stateObjectCache: { nameGlob: Glob }

- Defined in src/router/state/state-object.js:44

### $$state

$$state: () => StateObject

- Defined in src/router/state/state-object.js:33

### includes

includes: any = undefined

- Defined in src/router/state/state-object.js:26

### name

name: any = undefined

The state name (required)

A unique state name, e.g. `"home"`, `"about"`, `"contacts"`. To create a parent/child state use a dot, e.g. `"about.sales"`, `"home.newest"`.

Note: [State] objects require unique names. The name is used like an id.

- Defined in src/router/state/state-object.js:20

### navigable

navigable: any = undefined

- Defined in src/router/state/state-object.js:21

### params

params: any = undefined

Params configuration

An object which optionally configures parameters declared in the url, or defines additional non-url parameters. For each parameter being configured, add a [[ParamDeclaration]] keyed to the name of the parameter.

#### Example:

    params: {
      param1: {
       type: "int",
       array: true,
       value: []
      },
      param2: {
        value: "index"
      }
    }

- Defined in src/router/state/state-object.js:24

### parent

parent: StateObject = undefined

- Defined in src/router/state/state-object.js:23

### self

self: StateDeclaration

- Defined in src/router/state/state-object.js:39

### url

url: any = undefined

The url fragment for the state

A URL fragment (with optional parameters) which is used to match the browser location with this state.

This fragment will be appended to the parent state's URL in order to build up the overall URL for this state. See [[UrlMatcher]] for details on acceptable patterns.

#### Examples

    url: "/home"
    // Define a parameter named 'userid'
    url: "/users/:userid"
    // param 'bookid' has a custom regexp
    url: "/books/{bookid:[a-zA-Z_-]}"
    // param 'categoryid' is of type 'int'
    url: "/books/{categoryid:int}"
    // two parameters for this state
    url: "/books/{publishername:string}/{categoryid:int}"
    // Query parameters
    url: "/messages?before&after"
    // Query parameters of type 'date'
    url: "/messages?{before:date}&{after:date}"
    // Path and query parameters
    url: "/messages/:mailboxid?{before:date}&{after:date}"

- Defined in src/router/state/state-object.js:25

## Methods

### fqn

- fqn(): any

  #### Returns any

  Returns a dot-separated name of the state.

  #### Deprecated

  this does not properly handle dot notation

  - Defined in src/router/state/state-object.js:64

### is

- is(ref: any): boolean

  Returns true if the provided parameter is the same state.

  Compares the identity of the state against the passed value, which is either an object reference to the actual `State` instance, the original definition object passed to `$stateProvider.state()`, or the fully-qualified name.

  #### Parameters

  - ref: any

    Can be one of (a) a `State` instance, (b) an object that was passed into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.

  #### Returns boolean

  Returns `true` if `ref` matches the current `State` instance.

  - Defined in src/router/state/state-object.js:57

### parameter

- parameter(id: any, opts?: {}): any

  Returns a single [[Param]] that is owned by the state

  If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.

  #### Parameters

  - id: any

    the name of the [[Param]] to return

  - opts: {} = {}

    options

  #### Returns any

  - Defined in src/router/state/state-object.js:104

### parameters

- parameters(opts: any): any

  Gets the state's `Param` objects

  Gets the list of [[Param]] objects owned by the state. If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects. If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object

  #### Parameters

  - opts: any

    options

  #### Returns any

  - Defined in src/router/state/state-object.js:87

### root

- root(): any

  Returns the root node of this state's tree.

  #### Returns any

  The root of this state's tree.

  - Defined in src/router/state/state-object.js:75

### toString

- toString(): any

  Returns a string representation of an object.

  #### Returns any

  - Defined in src/router/state/state-object.js:111

### `Static` isState

- isState(obj: any): boolean

  Predicate which returns true if the object is an internal [[StateObject]] object

  #### Parameters

  - obj: any

  #### Returns boolean

  - Defined in src/router/state/state-object.js:118

### `Static` isStateDeclaration

- isStateDeclaration(obj: any): boolean

  Predicate which returns true if the object is a [[StateDeclaration]] object

  #### Parameters

  - obj: any

  #### Returns boolean

  - Defined in src/router/state/state-object.js:116