Skip to content

Commit e7eafd7

Browse files
rch850lacolaco
authored andcommitted
translate: guide/template-syntax.md のバインディング構文を翻訳
#505 の Binding syntax: an overview(バインディング構文: 概要)を翻訳しました。
1 parent 40f6c1f commit e7eafd7

1 file changed

Lines changed: 73 additions & 73 deletions

File tree

‎aio-ja/content/guide/template-syntax.md‎

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,21 @@ Angular の項の中で冪等な式は、
283283

284284
{@a binding-syntax}
285285

286-
## Binding syntax: an overview
286+
## バインディング構文: 概要
287287

288-
Data-binding is a mechanism for coordinating what users see, specifically
289-
with application data values.
290-
While you could push values to and pull values from HTML,
291-
the application is easier to write, read, and maintain if you turn these tasks over to a binding framework.
292-
You simply declare bindings between binding sources, target HTML elements, and let the framework do the rest.
288+
データバインディングは、アプリケーションのデータ値を使用して、
289+
ユーザーに表示される内容を調整するための仕組みです。
290+
HTML に値をプッシュしたり、プルしたりすることはできますが、
291+
これらの雑用をバインディングフレームワークに任せることで、アプリケーションの読み書きや保守が簡単になります。
292+
あなたはバインディングソースとターゲット HTML 要素の間のバインディングを宣言するだけで、あとはフレームワークにお任せです。
293293

294-
For a demonstration of the syntax and code snippets in this section, see the <live-example name="binding-syntax">binding syntax example</live-example>.
294+
このセクションで示す構文のデモとコードスニペットについては <live-example name="binding-syntax">バインディング構文の例</live-example>を参照してください。
295295

296-
Angular provides many kinds of data-binding. Binding types can be grouped into three categories distinguished by the direction of data flow:
296+
Angular はさまざまな種類のデータバインディングを提供します。バインディングタイプは、データフローの方向によって3つのカテゴリーに分類できます。
297297

298-
* From the _source-to-view_
299-
* From _view-to-source_
300-
* Two-way sequence: _view-to-source-to-view_
298+
* _ソースからビュー_
299+
* _ビューからソース_
300+
* 双方向シーケンス: _ビューとソースの双方向_
301301

302302
<style>
303303
td, th {vertical-align: top}
@@ -312,23 +312,23 @@ Angular provides many kinds of data-binding. Binding types can be grouped into t
312312
</col>
313313
<tr>
314314
<th>
315-
Type
315+
タイプ
316316
</th>
317317
<th>
318-
Syntax
318+
構文
319319
</th>
320320
<th>
321-
Category
321+
カテゴリ
322322
</th>
323323

324324
</tr>
325325
<tr>
326326
<td>
327-
Interpolation<br>
328-
Property<br>
329-
Attribute<br>
330-
Class<br>
331-
Style
327+
補間<br>
328+
プロパティ<br>
329+
属性<br>
330+
クラス<br>
331+
スタイル
332332
</td>
333333
<td>
334334

@@ -341,11 +341,11 @@ Angular provides many kinds of data-binding. Binding types can be grouped into t
341341
</td>
342342

343343
<td>
344-
One-way<br>from data source<br>to view target
344+
単方向<br>データソースから<br>ビューターゲットへ
345345
</td>
346346
<tr>
347347
<td>
348-
Event
348+
イベント
349349
</td>
350350
<td>
351351
<code-example>
@@ -355,12 +355,12 @@ Angular provides many kinds of data-binding. Binding types can be grouped into t
355355
</td>
356356

357357
<td>
358-
One-way<br>from view target<br>to data source
358+
単方向<br>ビューターゲットから<br>データソースへ
359359
</td>
360360
</tr>
361361
<tr>
362362
<td>
363-
Two-way
363+
双方向
364364
</td>
365365
<td>
366366
<code-example>
@@ -369,124 +369,124 @@ Angular provides many kinds of data-binding. Binding types can be grouped into t
369369
</code-example>
370370
</td>
371371
<td>
372-
Two-way
372+
双方向
373373
</td>
374374
</tr>
375375
</tr>
376376
</table>
377377

378-
Binding types other than interpolation have a **target name** to the left of the equal sign, either surrounded by punctuation, `[]` or `()`,
379-
or preceded by a prefix: `bind-`, `on-`, `bindon-`.
378+
補間以外のバインディングタイプは、等号の左側に **ターゲット名** があり、記号(`[]`、`()`)で囲まれているか、
379+
または接頭辞 `bind-`、`on-`、`bindon-` が前に付いています。
380380

381-
The *target* of a binding is the property or event inside the binding punctuation: `[]`, `()` or `[()]`.
381+
バインディングの *ターゲット* は、バインディングの記号 `[]`, `()`, `[()]` で囲まれたプロパティかイベントです。
382382

383-
Every public member of a **source** directive is automatically available for binding.
384-
You don't have to do anything special to access a directive member in a template expression or statement.
383+
すべての **ソース** ディレクティブのパブリックメンバは、自動的にバインディングできるようになっています。
384+
テンプレートの式や文からディレクティブのメンバにアクセスするために、特別に何かをする必要はありません。
385385

386386

387-
### Data-binding and HTML
387+
### データバインディングとHTML {@a data-binding-and-html}
388388

389-
In the normal course of HTML development, you create a visual structure with HTML elements, and
390-
you modify those elements by setting element attributes with string constants.
389+
通常の HTML 開発では、HTML 要素を使用して視覚的な構造を作り、
390+
文字列定数を要素の属性に設定することによってそれらの要素を変更します。
391391

392392
```html
393393
<div class="special">Plain old HTML</div>
394394
<img src="images/item.png">
395395
<button disabled>Save</button>
396396
```
397397

398-
With data-binding, you can control things like the state of a button:
398+
データバインディングを使えば、ボタンの状態などを制御することができます:
399399

400400
<code-example path="binding-syntax/src/app/app.component.html" region="disabled-button" header="src/app/app.component.html"></code-example>
401401

402-
Notice that the binding is to the `disabled` property of the button's DOM element,
403-
**not** the attribute. This applies to data-binding in general. Data-binding works with *properties* of DOM elements, components, and directives, not HTML *attributes*.
402+
バインディングの対象は、ボタンの DOM 要素の `disabled` プロパティで、属性 **ではない** ことに注意してください。
403+
これはデータバインディング一般に適用されます。データバインディングは、DOM 要素、コンポーネント、ディレクティブの *プロパティ* に対するもので、HTML *属性* に対するものではありません。
404404

405405

406-
### HTML attribute vs. DOM property
406+
### HTML 属性 vs. DOM プロパティ {@a html-attribute-vs-dom-property}
407407

408-
The distinction between an HTML attribute and a DOM property is key to understanding
409-
how Angular binding works. **Attributes are defined by HTML. Properties are accessed from DOM (Document Object Model) nodes.**
408+
HTML 属性と DOM プロパティの違いは、Angular バインディングがどのように機能するかを理解する上で非常に重要です。
409+
**属性は HTML によって定義されています。プロパティは DOM(Document Object Model)ノードからアクセスされます。**
410410

411-
* A few HTML attributes have 1:1 mapping to properties; for example, `id`.
411+
* いくつかの HTML 属性は、プロパティへの1対1のマッピングを持っています。`id` はその一例です。
412412

413-
* Some HTML attributes don't have corresponding properties; for example, `aria-*`.
413+
* 一部の HTML 属性には対応するプロパティがありません。`aria-*` はその一例です。
414414

415-
* Some DOM properties don't have corresponding attributes; for example, `textContent`.
415+
* 一部の DOM プロパティには対応する属性がありません。`textContent` はその一例です。
416416

417-
It is important to remember that *HTML attribute* and the *DOM property* are different things, even when they have the same name.
418-
In Angular, the only role of HTML attributes is to initialize element and directive state.
417+
たとえ同じ名前だったとしても、 *HTML 属性* と *DOM プロパティ* は別物だということを肝に銘じておきましょう。
418+
Angular での HTML 属性の役割は、要素やディレクティブの状態を初期化することだけです。
419419

420-
**Template binding works with *properties* and *events*, not *attributes*.**
420+
**テンプレートバインディングは *属性* ではなく *プロパティ* と *イベント* に対するものです。**
421421

422-
When you write a data-binding, you're dealing exclusively with the *DOM properties* and *events* of the target object.
422+
データバインディングを書くときは、対象のオブジェクトの *DOM プロパティ* と *イベント* だけを扱います。
423423

424424
<div class="alert is-helpful">
425425

426-
This general rule can help you build a mental model of attributes and DOM properties:
427-
**Attributes initialize DOM properties and then they are done.
428-
Property values can change; attribute values can't.**
426+
この一般的なルールは、属性と DOM プロパティのメンタルモデルを構築するのに役立ちます:
427+
**属性は DOM プロパティを初期化するとその役割を終えます。
428+
プロパティは変化します。属性は変化しません。**
429429

430-
There is one exception to this rule.
431-
Attributes can be changed by `setAttribute()`, which re-initializes corresponding DOM properties.
430+
このルールにはひとつだけ例外があります。
431+
属性は `setAttribute()` で変えることができ、それによって対応する DOM プロパティも再初期化されます。
432432

433433
</div>
434434

435-
For more information, see the [MDN Interfaces documentation](https://developer.mozilla.org/en-US/docs/Web/API#Interfaces) which has API docs for all the standard DOM elements and their properties.
436-
Comparing the [`<td>` attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) attributes to the [`<td>` properties](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement) provides a helpful example for differentiation.
437-
In particular, you can navigate from the attributes page to the properties via "DOM interface" link, and navigate the inheritance hierarchy up to `HTMLTableCellElement`.
435+
詳しくは、全ての標準 DOM 要素やそのプロパティについての API ドキュメントがある [MDN Interfaces documentation](https://developer.mozilla.org/en-US/docs/Web/API#Interfaces) を参照してください。
436+
[`<td>` の属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) と [`<td>` のプロパティ](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement) を見比べれば、より違いがはっきりするでしょう。
437+
具体的には、属性のページの "DOM interface" リンクをたどることでプロパティのページに移動でき、 `HTMLTableCellElement` まで継承の階層を移動できます。
438438

439439

440-
#### Example 1: an `<input>`
440+
#### 例 1: `<input>`
441441

442-
When the browser renders `<input type="text" value="Sarah">`, it creates a
443-
corresponding DOM node with a `value` property initialized to "Sarah".
442+
ブラウザが `<input type="text" value="Sarah">` をレンダリングするとき、
443+
ブラウザは `value` プロパティが "Sarah" で初期化された DOM ノードを作ります。
444444

445445
```html
446446
<input type="text" value="Sarah">
447447
```
448448

449-
When the user enters "Sally" into the `<input>`, the DOM element `value` *property* becomes "Sally".
450-
However, if you look at the HTML attribute `value` using `input.getAttribute('value')`, you can see that the *attribute* remains unchanged&mdash;it returns "Sarah".
449+
ユーザーが `<input>` に「Sally」と入力すると、DOM 要素の `value` プロパティは「Sally」になります。
450+
しかし、`input.getAttribute('value')` で HTML の `value` 属性を見れば分かる通り、 *属性* は変わらず「Sarah」のままです。
451451

452-
The HTML attribute `value` specifies the *initial* value; the DOM `value` property is the *current* value.
452+
HTML 属性の `value` は *初期値* を指定します。DOM の `value` プロパティは *現在* の値です。
453453

454-
To see attributes versus DOM properties in a functioning app, see the <live-example name="binding-syntax"></live-example> especially for binding syntax.
454+
実際に動くアプリで属性と DOM プロパティの違いを見るには、<live-example name="binding-syntax"></live-example> のバインディング構文を見てください。
455455

456-
#### Example 2: a disabled button
456+
#### 例 2: disabled ボタン
457457

458-
The `disabled` attribute is another example. A button's `disabled`
459-
*property* is `false` by default so the button is enabled.
458+
`disabled` 属性はもうひとつの例です。
459+
ボタンの `disabled` *プロパティ* のデフォルトは `false` なので、ボタンは有効な状態です。
460460

461-
When you add the `disabled` *attribute*, its presence alone
462-
initializes the button's `disabled` *property* to `true`
463-
so the button is disabled.
461+
`disabled` *属性* を追加すると、その存在だけでボタンの
462+
`disabled` *プロパティ* が `true` に初期化されるため、
463+
ボタンは無効になります。
464464

465465
```html
466466
<button disabled>Test Button</button>
467467
```
468468

469-
Adding and removing the `disabled` *attribute* disables and enables the button.
470-
However, the value of the *attribute* is irrelevant,
471-
which is why you cannot enable a button by writing `<button disabled="false">Still Disabled</button>`.
469+
`disabled` *属性* の追加と削除で、ボタンの無効、有効が切り換わります。
470+
しかし *属性* の値とは無関係なため、
471+
`<button disabled="false">Still Disabled</button>` と書いてボタンを有効にすることはできません。
472472

473-
To control the state of the button, set the `disabled` *property*,
473+
ボタンの状態を制御するには `disabled` *プロパティ* を設定します。
474474

475475
<div class="alert is-helpful">
476476

477-
Though you could technically set the `[attr.disabled]` attribute binding, the values are different in that the property binding requires to a boolean value, while its corresponding attribute binding relies on whether the value is `null` or not. Consider the following:
477+
技術的には属性バインディング `[attr.disabled]` を設定することはできますが、値は次のように異なります。プロパティバインディングがブーリアンの値を必要とするのに対して、対応する属性バインディングは、値が `null` かそうでないかを見ています。
478478

479479
```html
480480
<input [disabled]="condition ? true : false">
481481
<input [attr.disabled]="condition ? 'disabled' : null">
482482
```
483483

484-
Generally, use property binding over attribute binding as it is more intuitive (being a boolean value), has a shorter syntax, and is more performant.
484+
一般的には、属性バインディングよりもプロパティバインディングを使ったほうが、ブーリアンの値なのでより直感的で、構文も短く、パフォーマンスも良いです。
485485

486486
</div>
487487

488488

489-
To see the `disabled` button example in a functioning app, see the <live-example name="binding-syntax"></live-example> especially for binding syntax. This example shows you how to toggle the disabled property from the component.
489+
実際に動くアプリで `disabled` ボタンの動作を見るには、<live-example name="binding-syntax"></live-example> のバインディング構文を見てください。この例ではコンポーネントから disabled プロパティをトグルする方法を示しています。
490490

491491
## Binding types and targets
492492

0 commit comments

Comments
 (0)