---
title: Path
project: jComponent V20
version: 20.015
section: reference
language: de
license: MIT
url: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/path/
updated: 2026-11-18T13:58:14.460Z
---

# Path

> Die Eigenschaften und Methoden eines geparsten Paths.

Ein Path-Objekt enthält einen geparsten Path mit seinen Flags. Es steht als `component.path` und `plugin.path` zur Verfügung, und `new jComponent.Path(path)` erstellt eines. Die Syntax von Paths ist in [Paths](../../guides/paths/) und [Flags und Path-Modifikatoren](../../guides/flags/) erklärt.

## API

### path

Type: `property`

Der bereinigte Path ohne Flags.

Returns: `String` Der bereinigte Path ohne Flags.

Example: Path parsen
```js
var path = new jComponent.Path('form.user.name @touched #countries');
console.log(path.path);
// logs: form.user.name
console.log(JSON.stringify(path.flags));
// logs: {"touched":1}
console.log(path.cl);
// logs: countries
```

### raw

Type: `property`

Der Path mit seinen Flags, ohne Codelisten.

Returns: `String` Der Path mit seinen Flags, ohne Codelisten.

### flags

Type: `property`

Die Flags des Paths als Objekt.

Returns: `Object` Die Flags des Paths als Objekt.

Ein Flag ohne Wert hat den Wert `1`. Die Form `@key:value` behält den Wert.

### split

Type: `property`

Der Path, aufgeteilt in seine Ebenen, von der ersten bis zum gesamten Path.

Returns: `Array` Der Path, aufgeteilt in seine Ebenen, von der ersten bis zum gesamten Path.

### cl

Type: `property`

Die mit `#` geschriebenen Namen der Codelisten, durch Kommas getrennt.

Returns: `String` Die mit `#` geschriebenen Namen der Codelisten, durch Kommas getrennt.

### cache

Type: `property`

Der Text zwischen `<` und `>`.

Returns: `String` Der Text zwischen `<` und `>`.

### ERROR

Type: `property`

Ist `true`, wenn der Path das Schlüsselwort `ERROR` enthält.

Returns: `Boolean` Ist `true`, wenn der Path das Schlüsselwort `ERROR` enthält.

### SYNC

Type: `property`

Ist `true`, wenn der Path das Schlüsselwort `SYNC` enthält.

Returns: `Boolean` Ist `true`, wenn der Path das Schlüsselwort `SYNC` enthält.

### toString()

Type: `method`

Gibt den bereinigten Path zurück.

Returns: `String` Der Path.

Example: In einen String umwandeln
```js
var path = new jComponent.Path('form.name @touched');
console.log(path.toString());
// logs: form.name
```

### get(scope)

Type: `method`

Liest den Wert am Path.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |

Returns: `Object` Der Wert.

Example: In deinem eigenen Objekt lesen und schreiben
```js
var path = new jComponent.Path('user.name');
var scope = {};
path.set(scope, 'Anna');
console.log(JSON.stringify(scope), path.get(scope));
// logs: {"user":{"name":"Anna"}} Anna
```

### set(scope, value)

Type: `method`

Schreibt einen Wert an den Path, ohne etwas zu benachrichtigen.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |
| `value` | `Object` | yes |  | Der zu schreibende Wert. |

Fehlende übergeordnete Objekte werden angelegt.

### notify(scope, [flags])

Type: `method`

Benachrichtigt die Komponenten, Watcher und Binder, die an den Path gebunden sind.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |
| `flags` | `String` | no |  | Flags als String wie `@touched` oder als Objekt wie `{ touched: 1 }`. |

Example: Watcher benachrichtigen
```js
var path = new jComponent.Path('common.count');
WATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));
path.set(window, 5);
path.notify(window, '@touched');
// logs: 5 {"touched":1}
```

### assign(path)

Type: `method`

Erstellt einen Path relativ zu diesem.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `path` | `String` | yes |  | Der relative Path. |

Returns: `Path` Der neue Path.

Das Ergebnis hängt vom ersten Zeichen des Arguments ab:

| Argument | Ergebnis für `form.user` |
| --- | --- |
| `name` | `form.user.name` |
| `@touched` | `form.user` mit dem Flag |
| `?suffix` | `form.usersuffix` |
| `*name` | `common.name` |
| `#name` | `DEF.cl.name` |
| `%name` | `DEF.tmp.name` |

Ohne Argument gibt die Methode dasselbe Objekt zurück.

Example: Relative Paths bilden
```js
var path = new jComponent.Path('form.user');
console.log(path.assign('name').path);
// logs: form.user.name
console.log(path.assign('*name').path);
// logs: common.name
```

### includes(path, [partially])

Type: `method`

Gibt an, ob zwei Paths auf demselben Zweig liegen.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `path` | `String` | yes |  | Der zu vergleichende Path. |
| `partially` | `Boolean` | no | `false` | Vergleicht die letzte Ebene des Arguments. |

Returns: `Boolean` Das Ergebnis des Vergleichs.

Das Ergebnis ist `true`, wenn ein Path dem anderen übergeordnet ist oder beide gleich sind. Mit `partially` ist es auch `true`, wenn eine Ebene dieses Paths auf die letzte Ebene des Arguments endet.

Example: Paths vergleichen
```js
var path = new jComponent.Path('form.user');
console.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));
// logs: true true false
console.log(new jComponent.Path('form.user.name').includes('name', true));
// logs: true
```

### exec(callback)

Type: `method`

Löst die Flags des Paths aus, lädt seine Codelisten und ruft eine Funktion auf.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `callback` | `Function` | yes |  | Die aufzurufende Funktion. |

Jedes Flag wird als Event `@flag name` ausgelöst, mit dem Path als Argument.

Example: Flags eines Paths ausführen
```js
ON('@flag saved', path => console.log('flag', path));
new jComponent.Path('form.user @saved').exec(() => console.log('done'));
// logs: flag form.user
// logs: done
```

### find(scope, callback)

Type: `method`

Findet die bereiten Komponenten, die an den Path gebunden sind.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |
| `callback` | `Function` | yes |  | Eine Funktion `(components)`. |

Die Flags `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` und `@enabled` schränken das Ergebnis ein.

Example: Komponenten in einem Formular finden
```html
<ui-component name="field" path="form.name"></ui-component>
<ui-component name="field" path="form.email"></ui-component>

<script>
COMPONENT('field', function(self) {});

new jComponent.Path('form').find(window, function(components) {
    console.log(components.map(m => m.path.toString()).join());
});
// logs: form.name,form.email
</script>
```
