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

# Path

> Le proprietà e i metodi di un path analizzato.

Un oggetto Path contiene un path analizzato con i suoi flag. È disponibile come `component.path` e `plugin.path`, e `new jComponent.Path(path)` ne crea uno. La sintassi dei path è spiegata in [Path](../../guides/paths/) e in [Flag e modificatori di path](../../guides/flags/).

## API

### path

Type: `property`

Il path pulito, senza flag.

Returns: `String` Il path pulito, senza flag.

Example: Analizza un path
```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`

Il path con i suoi flag, senza elenchi di codici.

Returns: `String` Il path con i suoi flag, senza elenchi di codici.

### flags

Type: `property`

I flag del path sotto forma di oggetto.

Returns: `Object` I flag del path sotto forma di oggetto.

Un flag senza valore ha il valore `1`. La forma `@key:value` conserva il valore.

### split

Type: `property`

Il path suddiviso nei suoi livelli, dal primo fino al path completo.

Returns: `Array` Il path suddiviso nei suoi livelli, dal primo fino al path completo.

### cl

Type: `property`

I nomi degli elenchi di codici scritti con `#`, separati da una virgola.

Returns: `String` I nomi degli elenchi di codici scritti con `#`, separati da una virgola.

### cache

Type: `property`

Il testo scritto tra `<` e `>`.

Returns: `String` Il testo scritto tra `<` e `>`.

### ERROR

Type: `property`

È `true` quando il path contiene la parola chiave `ERROR`.

Returns: `Boolean` È `true` quando il path contiene la parola chiave `ERROR`.

### SYNC

Type: `property`

È `true` quando il path contiene la parola chiave `SYNC`.

Returns: `Boolean` È `true` quando il path contiene la parola chiave `SYNC`.

### toString()

Type: `method`

Restituisce il path pulito.

Returns: `String` Il path.

Example: Converti in stringa
```js
var path = new jComponent.Path('form.name @touched');
console.log(path.toString());
// logs: form.name
```

### get(scope)

Type: `method`

Legge il valore nel path.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |

Returns: `Object` Il valore.

Example: Leggi e scrivi nel tuo oggetto
```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`

Scrive un valore nel path, senza notificare nulla.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |
| `value` | `Object` | yes |  | Il valore da scrivere. |

Gli oggetti genitori mancanti vengono creati.

### notify(scope, [flags])

Type: `method`

Notifica i componenti, gli osservatori e i binder associati al path.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |
| `flags` | `String` | no |  | I flag come stringa, ad esempio `@touched`, o come oggetto, ad esempio `{ touched: 1 }`. |

Example: Notifica gli osservatori
```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`

Crea un path relativo a questo.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `path` | `String` | yes |  | Il path relativo. |

Returns: `Path` Il nuovo path.

Il risultato dipende dal primo carattere dell'argomento:

| Argomento | Risultato per `form.user` |
| --- | --- |
| `name` | `form.user.name` |
| `@touched` | `form.user` con il flag |
| `?suffix` | `form.usersuffix` |
| `*name` | `common.name` |
| `#name` | `DEF.cl.name` |
| `%name` | `DEF.tmp.name` |

Senza argomento, il metodo restituisce lo stesso oggetto.

Example: Costruisci path relativi
```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`

Indica se due path si trovano sullo stesso ramo.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `path` | `String` | yes |  | Il path da confrontare. |
| `partially` | `Boolean` | no | `false` | Confronta l'ultimo livello dell'argomento. |

Returns: `Boolean` Il risultato del confronto.

Il risultato è `true` quando un path è genitore dell'altro o quando sono uguali. Con `partially`, è `true` anche quando un livello di questo path termina con l'ultimo livello dell'argomento.

Example: Confronta i path
```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`

Emette i flag del path, carica i suoi elenchi di codici e chiama una funzione.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `callback` | `Function` | yes |  | La funzione da chiamare. |

Ogni flag viene emesso come evento `@flag name`, con il path come argomento.

Example: Esegui i flag di un path
```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`

Trova i componenti pronti associati al path.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |
| `callback` | `Function` | yes |  | Una funzione `(components)`. |

I flag `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` e `@enabled` limitano il risultato.

Example: Trova i componenti in un modulo
```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>
```
